none
Is it possible to get code coverage of underlying C# PS cmdlet code by running PowerShell scripts in the build system?

    Question

  • We currently have coded unit tests to exercise some of our C# PS cmdlet code, but are finding it tedious and it's simpler and more thorough if we exercise the code by running PS scripts.

    Is there a way to get code coverage (of the underlying C# code) from running PS scripts - and ideally a means of doing so from our TFS build system.

    Tuesday, December 05, 2017 11:48 AM

All replies

  • Hi David ,

     

    >> Is there a way to get code coverage (of the underlying C# code) from running PS scripts - and ideally a means of doing so from our TFS build system.

    Based on my understanding, there is no way to get code coverage from PowerShell Script task.

    But we could enable code coverage when use Visual Studio Test task in TFS build.

     

    Regards,

    Fletcher


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Wednesday, December 06, 2017 2:50 AM
  • Hi Fletcher,

    We are using the code coverage option in the VS Test facility.

    Thanks for confirming there's no easy way of getting code coverage via running PS scripts. I had searched but didn't find anything, but I wasn't sure if I was missing something that people in the know knew.

    Wednesday, December 06, 2017 12:19 PM
  • Hi David,

    Thanks for your response.

    After my researching , I found PowerShell Script could generate coverage reports using OpenCover. Reference: https://blogs.msdn.microsoft.com/powershell/2017/01/11/code-coverage-now-available-for-powershell-core/

    And, this blog description how to set up coverage reports on TFS with OpenCover.

    Hope it helps.

     

     

    Regards,

    Fletcher

     

    Note: This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you.

    Microsoft does not control these sites and has not tested any software or information found on these sites;

    Therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there.

    There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.

     


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Thursday, December 07, 2017 8:31 AM
  • Hi Fletcher,

    Thanks for pointing that out to that, I'll try to find time to have a look at it, but it might be a week or two (or more) while before I get round to it. I'll post back when I have.

    Thursday, December 07, 2017 5:06 PM
  • Sure.

    Looking forward to your reply.

      

    Regards,

    Fletcher


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Friday, December 08, 2017 5:30 AM