In this section:
You can monitor and collect coverage data from .NET managed code during manual or automated functional tests performed on a running web application that is deployed on IIS server. You can also send coverage data and test results to DTP. The application coverage information can be displayed in the DTP Coverage Explorer (see the "Coverage Explorer" chapter in the DTP user manual), which provides insights about how well the application is tested, as well as the quality of your tests.
The following components are required for collecting coverage:
- Internet Information Services (IIS) version 7.5 or higher
- Coverage Agent Manager (CAM) (contact your Parasoft representative) or SOAtest
dotTEST ships with a component called the coverage agent. The coverage agent is attached to the application under test (AUT) and monitors the code being executed as the AUT runs. When the coverage agent is attached to the AUT, a REST API is exposed that enables you to mark the beginning and end of each test and test session. During test execution, interactions with the coverage agent and AUT are written to a dynamic coverage data file, which contains markers that specify which lines of code were touched.
The steps that follow:
- dotTEST processes the dynamic coverage data and static coverage data, and merges them to create coverage.xml file.
- A coverage.xml file, which contains the coverage information, is sent to DTP.
- When DTP receives the coverage data, it's loaded into a coverage image, which is a special tag that enables you to aggregate coverage data from runs with the same build ID.
- The coverage image enables you to associate coverage information with specific tests.
Test results are also sent to DTP from the tool that executes the tests (i.e., SOAtest, tests executed by dotTEST, manual tests, etc.) in a report.xml file. If the build IDs for the coverage.xml file and the report match, DTP is able to correlate the data and display the coverage information.
If you use a source control system, ensure that your source control settings are properly configured; see Source Control Settings.
Configuring the Application Under Test for Coverage
The following steps are required to prepare the application under test (AUT):
- The static coverage file must be generated. The static coverage file contains metadata about user classes, methods, and lines; see Generating the Static Coverage File.
- The coverage agent must be attached to the AUT; see Attaching the Coverage Agent to the AUT.
Generating the Static Coverage File
Run the following test configuration on the solution:
The dottestcli console output indicates where the static coverage data is saved, for example:
Customizing Scope of Coverage
By default, coverage is measured for the entire application. To narrow down the scope of collecting static coverage:
Provide paths to the selected parts of the application with the
-resourceoption points to a path inside the solution; the
-exclude options specify paths in the file system (see for details). Your command line may resemble the following:
When static coverage is generated, the scope information is stored in a scope configuration file. The output from the console indicates the location of the scope configuration file, for example:
Pass the path to the scope configuration file to the dotTEST IIS Manager tool (see Attaching the Coverage Agent to the AUT) with the
-scopeoption, for example:
You don' need to modify the content of the scope configuration file. However, if you collect coverage for large applications, you may want to additionally fine-tune the scope for collecting dynamic coverage (i.e. coverage collected while interacting with the application under test) to optimize performance. To customize collecting dynamic coverage, open the scope.instumentation.txt file and remove the the assemblies for which you do not want to collect coverage data from the list of assemblies.
It is not possible to use the application coverage scope file for web projects that are compiled on IIS. This is because the target assemblies of IIS compilations are named unpredictably. Scope files can be used safely when the assembly name loaded by IIS can be predetermined before coverage collection starts.
Attaching the Coverage Agent to the AUT
- Copy the [INSTALLATION_DIR]\integration\IIS directory to the machine were IIS is installed and the web application is deployed.
- Run a console as an Administrator
Invoke the dotTEST IIS Manager tool on this machine to enable runtime coverage collection inside IIS:
You may need to configure the dotTEST IIS Manager with additional options, see IIS Manager Options.
dottest_iismanager initializes the environment for the web server (IIS) and behaves like a service, enabling you to execute tests and collect coverage. The service is ready and waiting for commands as long as the following message is printed to the output:
A test session and test can be started even if the tested website or application has not been loaded yet.
- Ensure that port 8050 (default port for the coverage agent) allows HTTP traffic in firewall settings on this machine. You can change the coverage agent port number if the default port is unavailable.
- Open the website or application.
Go to the following address to check the status of the coverage agent:
You should receive the following response:
Collecting Coverage from Multiple Users
You can collect coverage information for multiple users that are simultaneously accessing the same web application server. This requires launching the dotTEST IIS Manager with the
See the Coverage Agent Manager (CAM) section of the DTP documentation for details.
Changing IIS Idle Timeouts
By default, IIS application pool processes are recycled after 20 minutes of idle time, which can have negative consequences on a test session. You can prevent this behavior by changing the default value so that people working with the application do not experience unexpected stops and restarts during a test session.
- Start the Internet Information Services (IIS) Manager.
- Open the Application Pools node.
- Choose the pool for your web application.
- Click Advanced Settings in the Actions panel.
- In Process Model section, change the Idle Time-out (minutes) setting to a value better-suited to your testing practices.
IIS Manager Options
|-scope||A path to the scope configuration file. Required if the scope is other than the default; see Customizing Scope of Coverage.|
Specifies the timeout for connection with the Coverage Agent. Adjust the timeout to your machine capabilities. The default value is 1500 ms.
If you provide 0 or a negative value, the connection attempt will not timeout, which may lead to a considerable slowdown or hang the tool.
|-port||Specifies the port number when you start dottest_iismanager if the default port is unavailable.|
|-multiuser||Enables collecting coverage information for multiple users; see Collecting Coverage from Multiple Users.|
Uploading Test Results to DTP
If you use dotTEST with CAM
- Go to Report Center in the DTP interface.
- Click the gear icon and choose Report Center Settings> Additional Settings> Report Center Administration> Tools> Data Collector Upload Form (requires admin permissions).
- Click Choose File and browse for the report.xml file you downloaded from CAM.
- Click the Upload button to upload the file to DTP.
If you use SOAtest
For tests executed by SOAtest, the SOAtest XML report will need to be uploaded to DTP. See the "Uploading Rest Results to DTP" section in the Application Coverage topic in the SOAtest documentation for details.
Generating a Dynamic Coverage Data File and Uploading It to DTP
- Ensure that dotTEST is properly configured, including DTP, scope and authorship settings. See Connecting to DTP, , Configuration.
- Configure the following settings in the dottestcli.properties file in order to properly merge coverage data:
report.coverage.images- Specifies a set of tags that are used to create coverage images in DTP. A coverage image is a unique identifier for aggregating coverage data from runs with the same build ID. DTP supports up to three coverage images per report.
session.tag- Specifies a unique identifier for the test run and is used to distinguish different runs on the same build.
build.id- Specifies a build identifier used to label results. It may be unique for each build, but it may also label several test sessions executed during a specified build.
Copy the runtime coverage and static coverage files to the same machine and run
dottestcliwith the following switches:
-runtimeCoverage: Specifies the path to runtime coverage that you download with CAM (see Coverage Agent Manager (CAM) section of the DTP documentation for details). You can provide a path to an individual .data file with coverage information from one testing session, or a path to a folder that contains many .data files from multiple testing sessions.
-staticCoverage: Specifies the path to the static coverage file (see Generating the Static Coverage File).
-publish: Sends the merged coverage to DTP.
Stopping Dynamic Coverage Data Collection
You can stop the process of collecting dynamic coverage data in one of the following ways:
exitin the open console when the following message will be printed to the output to stop dottest_iismanager:
Send a request to the service by entering the following URL in the browser:
Stop dottest_iismanager only when all test sessions are finished. Application coverage will no longer be collected when the service stops, so it is important that dottest_iismanager runs continously while performing tests to collect coverage.
If any errors occur when dottest_iismanager exits, which prevent the clean-up of the Web Server environment, then execute dottest_iismanager with the
-stop option to bring back the original Web Server environment and settings:
Reviewing Coverage in DTP
You can use the Coverage Explorer in DTP to review the application coverage achieved during test execution. See the DTP documentation for details on viewing coverage information.
- You can download coverage information that was collected in a test session. Coverage data collected when no test session was active cannot be downloaded.
- If multiple users are simultaneously accessing the same web application, the coverage data they collect may be mixed. To ensure that coverage is properly associated with individual users, the multiuser mode must be enabled (see Collecting Coverage from Multiple Users).
- The HTTP or HTTPS protocols are required to enable the multiuser mode, as the user-specific information must be provided within the HTTP header.
- In the multiuser mode, collecting coverage for WCF-based applications requires that they have the ASP.NET compatibility mode enabled.
- In the multiuser mode, the "default" user (the user who has not specified their ID) may collect extra coverage information from other users who are accessing the same web application.
- In the multiuser mode, assigning coverage collected for multithreaded application to individual users is limited. Coverage data for child threads is not assigned to the user who is actually accessing the application, but to the "default" user.
- Coverage data collected web initialization is not assigned to a specific user, but to the "default" user.
- The application coverage scope file cannot be used for WebSite projects as they may get recompiled by IIS server and change the name of the target assembly. Scope files can be safely used for Web Applications.