Using "code coverage coloring" to help debuging

Source: Internet
Author: User

when I tried to investigate a defect, usually the first thing that I want to verify is the "RunTime" execution flow. and if the "RunTime" flow didn't match the "expected" flow, I wocould be very close to the root cause of a defect. however, sometimes it's not very easy to tell the "real/RunTime" execution flow (especially when you can't attach your debugger to the target assembly, or when the defect can't be reproduced stably ). I used to add more debug info output to the logs to help me out, and sometimes it cocould be a very tedious and time-consuming process.

so, basically I need something like the "code coverage coloring" functionality, which is supported by vs ut. I want the assemblies (deployed in integration Lab) to generate the code coverage automatically when the manual or automatic test is taken, and I need a UI to load the coverage result to show me which code line is executed during the test. then, it wocould be much easier for me to find the "real" execution flow. A performance profiling tool (like aqtime) cocould definitely make it, but they are too "huge" for my simple requirements. all I need actually is only a lightweight tool which cocould instrument my assemblies, and make the instrumented assembles to output Coverage Information of line level. and, if the coverage information has the same structure as vs ut, I cocould use vs to open it.

MS doesn't disappoint me, and all what I need are supported by vs's tool box:
Vsinstr.exeWill help to instrument binary, andVspercmd.exeWill help to start and stop the profiling process.
If you have vs installed on your test machine, you already have them under the path (for vs2010)
C: \ Program Files (x86) \ Microsoft Visual Studio 10.0 \ team tools \ Performance Tools.
If your test environment doesn't have vs installed (like me), copy the executables and the depended DLLs to your test machine. in my test box, all I need to copy is like bellow:

If you are not sure about the dependency of the executables, windbg cocould help you. Below is an example of all the DLLs that vsinstr.exe need.

Now, the last thing is, how to used the tools, and it's as easy as I expected.
1. instrument you assembly, the "/coverage" option is a must
Vsinstr.exe your_assembly/coverage
If you are interested, you can take a look at the instrumented result, like below:

2. Start the monitor Vsperfw..exe/start: coverage/CS/output: Filename
3. Start the program which you want to test, and then do manual or automatic ic test as you need
4. After your test is ended, shutdown the monitor Vsperfcmd.exe/Shutdown
5. view the output coverage file by.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.