In this section:
You can monitor and collect coverage data from managed code during manual or automated functional tests performed on a running web application that is deployed on IIS server.
dotTEST can collect coverage for .NET web applications that are deployed on IIS server. Alternatively, you can use the |
The dotTEST 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. dotTEST processes the collected coverage data and creates a coverage.xml file, which can be sent to DTP.
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. |
To collecting coverage, Internet Information Services (IIS) version 7.5 or higher is required.
The following steps are required to prepare the application under test (AUT):
Invoke the Agent Client tool on this machine to enable runtime coverage collection inside IIS:
agent_client.exe |
You may need to configure the Agent Client with additional options, see Agent Client Options.
agent_client 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:
Write 'exit' and hit Enter to close agent_client |
A test session and test can be started even if the tested website or application has not been loaded yet. |
Go to the following address to check the status of the coverage agent: http://host:8050/status
You should receive the following response:
{"session":null,"test":null} |
By default, the coverage agent is available via the HTTP protocol. To connect via HTTPS, you need to bind an SSL certificate to the port used by the coverage agent. This can be achieved in one of the following ways:
By adding your SSL certificate to a storage accessible from the Netsh.exe tool and passing the hash of the certificate and the port number to agent_client.exe:
agent_client.exe -port 8050 -useSsl -certificateHash <SSL certificate hash> |
By passing the path and password to an SSL certificate stored in a .pfx file and the port number to agent_client.exe:
agent_client.exe -port 8050 -useSsl -certificatePath <path to PFX> -certificatePassword <password> |
By configuring a port with an SSL certificate and the appid
of the Agent Client for the Netsh.exe tool. The Agent Client has the following ID:
{ed344e08-fab7-4dfb-9d07-68f2c2c9e373} |
When the SSL certificate is configured in the Netsh.exe tool, you can connect via HTTPS by launching the Agent Client with the -port
and -useSsl
switches:
agent_client.exe -port 8050 -useSsl |
To use a self-signed certificate, you must add the -skipvalidation
option.
You can use an SSL certificate in the in PFX or PKCS12 format.
By default, the Agent Client automatically handles certificates configured for the coverage agent. To manually remove a certificate, launch the Certmgr.exe tool and remove the certificate stored in Personal> Certificates.
If you manually unregister the coverage service port using the Agent Client with the -unregister
switch, you need to add the -useSsl
and -removeCertificate
switches to remove the SLL certificate:
agent_client.exe -unregister -port 8050 -useSsl -removeCertificate |
This will delete the SSL certificate from the port number. You can now manually remove the certificate from the storage.
You can collect coverage information for multiple users that are simultaneously accessing the same web application server. This requires launching the Agent Client with the -multiuser
switch:
agent_client.exe -multiuser |
By default, the Agent Client 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.
Option | Value | Description | |
---|---|---|---|
-scope | <path> | A path to the scope configuration file. Required if the scope is other than the default; see Customizing Scope of Coverage with dottestcli. | |
-agentTimeout | <miliseconds> | Specifies the timeout for connection with the coverage agent. Adjust the timeout to your machine capabilities. The default value is 1500 ms.
| |
-port | <port number> | Specifies the port number when you start agent_client if the default port is unavailable. | |
-multiuser | Enables collecting coverage information for multiple users; see Collecting Coverage from Multiple Users. | ||
-useSsl | Enables connecting via HTTPS; see Connecting with the the Coverage Agent via HTTPS. | ||
-certificateHash | <SSL certificate hash> | Specifies the hash of the SSL certificate for the port that is used by the coverage agent; see Connecting with the Coverage Agent via HTTPS. | |
-certificatePath | <path> | Specifies the path to a PFX file that stores the SSL certificate; Connecting with the Coverage Agent via HTTPS. | |
-certificatePassword | <password> | Specifies the password to the SSL certificate stored in a PFX file; see Connecting with the Coverage Agent via HTTPS. | |
-displayappid | Prints the 'appid' of the Agent Client; see Connecting with the Coverage Agent via HTTPS. | ||
-removeCertificate | Removes the SSL certificate when the port is manually unregistered with the -unregister switch; see Connecting with the Coverage Agent via HTTPS. | ||
-skipvalidation | Enables using a self-signed SSL certificate; see Connecting with the Coverage Agent via HTTPS. |
To collect runtime coverage:
You can stop the process of collecting runtime coverage data in one of the following ways:
Write exit
in the open console when the following message will be printed to the output to stop agent_client:
Write 'exit' and hit Enter to close agent_client |
Send a request to the service by entering the following URL in the browser: http://host:port/shutdown
Stop agent_client only when all test sessions are finished. Application coverage will no longer be collected when the service stops, so it is important that agent_client runs continuously while performing tests to collect coverage. |
If any errors occur when agent_client exits, which prevent the clean-up of the Web Server environment, then execute agent_client with the -stop
option to bring back the original Web Server environment and settings:
agent_client.exe -stop |
See Creating a Coverage Report and Uploading the Data to DTP.