Previous Topic Next topic Print topic


Code Coverage and Profiling (.NET COBOL)

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

  1. In Visual Studio, build your .NET COBOL application with Compile for debugging enabled on the COBOL tab in the project's properties.
  2. 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.

  3. At the command prompt, change to the output directory of the solution where the application executable is created.
  4. Execute the following at the command prompt to generate the instrumented binaries:
    VSIinstr -coverage app-filename.exe
  5. 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.

  6. Run your application.
  7. Execute the following to close the Visual Studio Performance Profiler:
    VSPerfCmd /shutdown
  8. 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

  1. In Visual Studio, click Analyze > Launch Performance Wizard.
  2. Choose the default option, CPU Sampling, and click Next.
  3. Click An executable (.EXE file), and then click Next.
  4. Specify the full path to the application executable and the Working directory, click Next.
  5. Click Finish to start profiling your application.

    The profiler launches your application.

  6. Run the application and, when it finishes, Visual Studio generates the profiling report.

To rerun Profiler with a different setting such as Instrumentation:

  1. In Performance Explorer, right-click the current profiling session, and click Properties.
  2. On the General page, click Instrumentation, and then click OK.
  3. 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.

Previous Topic Next topic Print topic