code coverage "off road"

I've tried using the sample from http://blogs.msdn.com/ms_joc/articles/406608.aspx to get the off-road experience of code coverage. However, when I run the tests on my instrumented binary, I'm getting the coverage results for the test project instead of my instrumented binary. Am I missing something here!


Answer this question

code coverage "off road"

  • Bilgehan

    Here are some things to check on that might help:

    1) Don't instrument the test binaries unless you want coverage data on them.
    2) Make sure you execute the same assembly you instrumented.
    3) If the assembly is registered in the registry or is accessed by path, make sure you've instrumented the one being picked up.
    4) When you start the monitor (vsperfmon.exe) do you see the console window   If so, verify the assembly gets registered when you execute it.  If you don't see it, you aren't executing the instrumented assembly.

    Chris
    Microsoft Corporation


  • Dmitry Vasilevsky MSFT

    Can you send me information about TS-ing into your machine via email to munjald@microsoft.com I am pretty sure the problem is very basic (especially since it is a C# console application after all) and I will not take long before I find out the real problem.

    Please send information about login credentials and the project path, etc. and the steps you are performing.


  • Martin Szugat

    I've tried the steps mentioned by you and also tried copying all the related PDBs, EXEs, DLLs (of testproject1 and ConsoleApplication1) into a common folder and then tried the same steps. Still I get the same result.

    Will try again and let you know if I hit on something!

  • MaTT_17

    yes I've verified that the instrumented binary is in the bin directory of the test proj.

  • Adatacorp

    http://blogs.msdn.com/vstsqualitytools/archive/2005/06/08/426979.aspx is another article that the Team Test team wrote to help with off-roading with Coverage and Testing.

  • Aicos

    Hi Chris,

    I'm instrumenting my assembly and able to generate the .instr file, and executing the mstest.exe using the testcontainer switch and loading the testproject dll that houses the tests for my assembly.

    However, vsperfmon is not picking the instrumented assembly. Is there any way that I can tell vsperfmon to load a particular instrumented assembly Do I need to do this I'm using

    vsperfmon - coverage /output:@"E:\samples\MyCoverage.coverage"



  • Fairy

    I think it is time you check the path of the module loaded into the vstesthost.exe process to find out what binary is actually loaded versus what binary is instrumented.

    Did you already verify that the binary being instrumented is not in the bin directory of the console application but in the bin directory of the test project

    If nothing works, just let me TS into your machine and I will find out the issue.

    -Munjal (MS)


  • Elfman

    If you try the following, you should get data on the executable.  Does this work for you   If it does, make sure the test project is calling this executable.

    1) Build the project
    2) vsinstr -coverage realcode.exe
    3) vsperfmon -coverage -output:realcode.coverage
    4) realcode.exe
    5) vsperfcmd -shutdown


  • Cobo

    yes, I'm doing the exact same steps. It is a regular console app (.exe) using C#.

  • Ron A. Buckton

    I've tried the very steps, yet unable to get coverage info for my assembly. Still continuing to get results for the test project :(

    Scenario 3: Product and Test Binaries Only - is my current scenario



  • Joey.Liang

    I suspect you are instrumenting the console application in its own bin directory and not in the bin directory of the test project.

    That is, let's say you have the following folder structure:

    Solution1
    --> ConsoleApplication1
    --> TestProject1

    And you have a reference from the test project to the console application. That is you have the following files:

    Solution1
    --> ConsoleApplication1
         -->bin
              --> Debug
                    --> ConsoleApplication1.exe
    --> TestProject1
               -->bin
              --> Debug
                    --> TestProject1.dll
                    --> ConsoleApplication1.exe

    I think you are instrumenting Solution1\ConsoleApplication1\bin\Debug\ConsoleApplication1.exe while you should actually be instrumenting Solution1\TestProject1\bin\Debug\ConsoleApplication1.exe

    One way to easily locate the problem (or confirm that you are doing the above thing) is to attach a debugger to VSTestHost.exe (that is the process that mstest.exe will ultimately call) and look into the modules view what is the path for consoleapplication1.exe being loaded.

    Hope this helps. Let us know what you find out.

    -Munjal (MS)



  • Sillychuckie

    vsperfmon collects data on instrumented binaries that are executed.  In the off-road case, you are responsible for making sure you execute the correct binary.  What kind of binary are you instrumenting (C++, C#, dll, exe)   Is this binary registered in any way (COM)

    I assume you're doing something like the following.  Is this right

    1) Build the project
    2) Build the test project
    3) vsinstr -coverage realcode.dll
    4) vsperfmon -coverage -output:mycoverage.coverage
    5) mstest /testcontainer:testproject.dll ...
    6) vsperfcmd -shutdown


  • code coverage "off road"