You can use Visual Studio's integrated tools to collect code coverage and performance information for .NET COBOL applications.
Restriction: The current limitations include:
- Visual Studio Professional or a more advanced edition is required to collect coverage information. Visual Studio Premium or a more advanced edition is required to view
.coverage files in the IDE.
- Visual Studio Premium or a more advanced edition is required if you are using C# or Visual Basic test projects to collect code coverage data for .NET COBOL applications.
- The expanded copybook view sometimes shows incorrect code coverage information.
- Profiling shows compiler-generated method names - for example, when the code being profiled is procedural (non-Object Oriented managed) COBOL.
Collecting code coverage using Profiler
- In Visual Studio, build your .NET COBOL application with
Compile for debugging enabled on the
COBOL tab in the project's properties.
- Start a Visual Studio command prompt with elevated rights.
You need the 32-bit Visual Studio command prompt for applications compiled for x86 and the 64-bit Visual Studio command prompt if the application you are testing is compiled with x64 or AnyCPU.
- At the command prompt, change to the output directory of the solution where the application executable is created.
- Execute the following at the command prompt to generate the instrumented binaries:
VSIinstr -coverage app-filename.exe
- Execute the following to start the Profile monitor for code coverage and to create a
.coverage file:
VSPerfCmd /start:coverage /output:run.coverage
This creates a
run.coverage file in the output directory of the solution.
- Run your application.
- Execute the following to close the Visual Studio Performance Profiler:
VSPerfCmd /shutdown
- In Visual Studio, click
File > Open > File, navigate to the output directory of the solution, and select and open the
run.coverage file. (You must have Visual Studio Premium or Ultimate to view
.coverage files in the IDE.)
Collecting code coverage through tests
You can collect code coverage by running your application using tests.
Enterprise Developer does not provide Visual Studio test projects for COBOL so you need to create either a C# or a VB test project that references and runs COBOL.
Restriction: This is only supported in Visual Studio Premium or Ultimate edition.
Performance profiling of .NET COBOL code
- In Visual Studio, click
Analyze > Launch Performance Wizard.
- Choose the default option,
CPU Sampling, and click
Next.
- Click
An executable (.EXE file), and then click
Next.
- Specify the full path to the application executable and the
Working directory, click
Next.
- Click
Finish to start profiling your application.
The profiler launches your application.
- Run the application and, when it finishes, Visual Studio generates the profiling report.
To rerun Profiler with a different setting such as Instrumentation:
- In Performance Explorer, right-click the current profiling session, and click
Properties.
- On the
General page, click
Instrumentation, and then click
OK.
- In Performance Explorer, right-click the current profiling session, and click
Start Profiling.
For more information on Performance Profiling, Code Coverage and other Visual Studio analysis tools, check Microsoft's MSDN.