Did you ever wish you could run DevPartner’s BoundsChecker, TrueTime, or even TrueCoverage from inside of Visual Studio while waiting for a process to start? I will walk you through how I was able to configure a tool bar button in Visual Studio that will allow me to configure DevPartner Code Coverage to wait for a process to start and then launch the process using the debugger (F5).
The reason that I was looking in to this is because of a bug that was recently discovered by one of our Chinese customers. The problem that they are having is that when they launch their website using Code Coverage, the webserver would start, shutdown, and then restart. Because of the restart, DevPartner Code Coverage was not able to capture the coverage data for the newly launched session of the webserver.
The work around for the customer was to use dpanalysis.exe to start DevPartner Code Coverage and have it wait for WebDev.WebServer40.exe to start. The only problem is that the developer or QA person has to open a command prompt each time they want to run Code Coverage against their application. So what I did was create a batch file that I could add to the External Tools menu in Visual Studio.
Here is the content of the batch file that I created (This could be easily modified to support any application):
@echo offecho Stopping WebDev.WebServer40.exe.taskkill /im WebDev.WebServer40.exeecho Configuring DevPartner Analysis for Code Coverage."%ProgramFiles(x86)%\Micro Focus\DevPartner Studio\Analysis\DPAnalysis.exe" /cov /e /w %temp% /nowait /p "%CommonProgramFiles(x86)%\microsoft shared\DevServer\10.0\WebDev.WebServer40.EXE"echo Please start debugging web site by pressing F5 or Ctrl-F5.echo When done testing, press the stop button in the Session Control window.
The next thing that I did was to create a menu item in Visual Studio by selecting “Tools->External Tools…” in Visual Studio. The following dialog will display:
Press the “Add” button and enter the following data:
Title: Configure Coverage for WebDev.WebServer40.exeCommand: <Location and name of attached batch file>
Also check “Use Output windows”. This will redirect the output of the command to the output window in Visual Studio.
That is it. Now when I select “Tools->Configure Coverage for WebDev.WebServer40.exe” and press F5 or Ctrl-F5 and run my website, DevPartner’s Code Coverage will collect coverage data. When I am done executing my website, I close Internet Explorer and press the “Stop” button in the Coverage Session Control Window.
The DevPartner Code Coverage Session file will open and display the results.
That’s it. If you want, you can now create a new toolbar and add the external tool that we created above.