...
Application servers usually contain more than one application. Additionally, common server classes or application libraries do not need to be instrumented. The agent only needs to collect coverage for application source code. Instrumenting all classes would be too time consuming. For this reason, properly setting the scope of the coverage agent is very important. There are coverage agents for Jtest and dotTEST.
Anchor | ||||
---|---|---|---|---|
|
You can configure the Jtest coverage agent by modifying the properties in the agent.properties and passing the properties to the -javaagent
argument. The agent supports several parameters (see Coverage Agent Parameters), but configuring the default settings is suitable for most cases:
No Format |
---|
jtest.agent.serverEnabled=true jtest.agent.includes=com/myapp/data,com/myapp/common/** jtest.agent.excludes=com/myapp/transport/*,com/myapp/autogen/** |
Anchor | ||||
---|---|---|---|---|
|
The following table describes all properties that can be set for the agent:
jtest.agent.runtimeData | Specifies a location on the application server for the agent to store the coverage data it collects at runtime. The following example will create files in the in
| |
---|---|---|
jtest.agent.includes | A comma-separated list of patterns that specify classes to be instrumented. The following wildcards are supported:
In the following example, all classes from the
| |
jtest.agent.excludes | A comma-separated list of patterns that specify classes to be excluded from instrumentation. The following wildcards are supported:
In the following example, all classes from the
| |
jtest.agent.autostart | Enables/disables automatic runtime data collection | ; the. The default is true . |
jtest.agent.port | Sets up agent communication port | ; the. The default is 8050 . |
jtest.agent.debug | Enables/disables verbose output to console | ; the. The default is false . |
jtest.agent.enableMultiuserCoverage | Enables/disables collecting web application coverage for multiple users; the . The default is | |
jtest.agent.serverEnabled autoloadMultiuserLibs | Enables/disables automatic loading of multiuser libraries (OpenTelemetry javaagent) when jtest.agent.enableMultiuserCoverage is set to true. The default value is true . | |
jtest.agent.serverEnabled | Activates Activates the agent. | |
jtest.agent.enableJacoco | Enables the agent to collect coverage using the JaCoCo engine | ; the. The default is false. |
When the properties are configured, add a -javaagent
argument when starting your application server to attach the agent and include the agent configuration file:
...
You can also check the directory you specified with the runtimeData property (/home/TIA/coverage_storage
in the example above). The directory should contain a set of static coverage data files. The files are generated when the agent is started.
dotTEST Coverage Agent
Additional Steps for Multiuser Mode
If you are enabling multiuser coverage and multiple users are simultaneously accessing the same web application, the coverage data they collect may be mixed. To prevent this, there are a few additional steps:
Your tests need to inject the following HTTP header:
baggage: test-operator-id=<USER>
- Be sure that both
jtest.agent.enableMultiuserCoverage
andjtest.agent.autoloadMultiuserLibs
are enabled (see Jtest Coverage Agent).
Also bear in mind that in multiuser mode:
- When
jtest.agent.enableMultiuserCoverage
is enabled, jtest-otel-ext.jar and opentelemetry-javaagent.jar will be automatically loaded from the agent.jar directory. - 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.
- Coverage collected for multithreaded applications may, in some cases, not be assigned to individual users. This is related to OpenTelemetry limitations regarding context sharing between threads.
- Collecting coverage with the Jacoco engine is not supported.
- Coverage data collected for web application initialization is not assigned to a specific user, but to the "default" user.
dotTEST Coverage Agent
The dotTEST coverage agent can collect coverage for web applications and standalone applicationsThe dotTEST coverage agent can collect coverage for web applications and standalone applications. Each requires a different configuration.
...
- Copy the
<INSTALL_DIR>/coverage/dotNET/dottest_agent
folder to the machine where IIS is installed and the web application is deployed. - Run a console as an Administrator on this machine.
Invoke the Agent Client tool on this machine to enable runtime coverage collection inside IIS:
Code Block agent_client.exe
Note: If you want to collect coverage information for multiple users that are simultaneously accessing the same web application server, invoke the Agent Client with the
-multiuser
switchInvoke the Agent Client tool on this machine to enable runtime coverage collection inside IIS:Code Block agent_client.exe -multiuser
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:Code Block Write 'exit' and hit Enter to close agent_client
Info 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.
Start the application and verify that the agent is ready by opening
<host>:8050/status
in your browser. You should receive the following response:Code Block {"session":null,"test":null}
Configure soatest.properties to collect coverage for the AUT. Several application coverage parameters are supported (see Application Coverage Settings), but configuring the following settings is suitable for most cases:
Code Block application.coverage.enabled=true application.coverage.agent.url=http://localhost:8050 application.coverage.binaries=c:/<PATH_TO_APPLICATION_PDB_FILES>/bin application.coverage.binaries.include=<INCLUDE_PATTERN> application.coverage.binaries.exclude=<EXCLUDE_PATTERN>
Be sure the path for the application binaries
.exclude=<EXCLUDE_PATTERN>Be sure the path for the application binaries is to the folder containing the application PDB files.
...
is to the folder containing the application PDB files.
Additional Steps for Multiuser Mode
If you are enabling multiuser coverage and multiple users are simultaneously accessing the same web application, the coverage data they collect may be mixed. To prevent this, there are a few additional steps:
Your tests need to inject the following HTTP header:
baggage: test-operator-id=<USER>
Standalone Applications
Most users will collect coverage for web applications, but you can also collect coverage information from standalone applications.
- Copy the
<INSTALL_DIR>/coverage/dotNET/dottest_agent
folder to the machine where you intend to run the standalone application. - Run the coverage_wizard.exe in that folder, specifying the following:
- Full path the application
- Command line arguments
- Working directory
- Select the .NET CLR version used by the application.
- Enter the directory where the scripts generated by the wizard will be saved in the Target scripts directory field.
- Enable the Use Coverage Agent option and enable or disable the Collect coverage without admin privileges option as appropriate.
- By default, admin privileges are required to collect coverage with coverage agent, but you can configure the tool to collect coverage by users without admin privileges. Doing so will cause two additional .bat scripts to be generated: runCamAgentInit.bat and runCamAgentUninit.bat. Run the runCamAgentInit.bat script with admin privileges to setup and initialize the coverage agent. When testing is completed, run the runCamAgentUninit.bat script to stop the process.
- Click Finish. The wizard will generate scripts in target script directory specified above.
- Run a console as an Administrator on this machine and change directories to where the scripts were generated.
- Execute runCamAgent.bat.
- Run another console as an Administrator and execute monitorCoverage.bat.
Configure soatest.properties to collect coverage for the AUT. Several application coverage parameters are supported (see Application Coverage Settings), but configuring the following settings is suitable for most cases:
Code Block application.coverage.enabled=true application.coverage.agent.url=http://localhost:8050 application.coverage.binaries=c:/<PATH_TO_APPLICATION_PDB_FILES>/bin application.coverage.binaries.include=<INCLUDE_PATTERN> application.coverage.binaries.exclude=<EXCLUDE_PATTERN>
Be sure the path for the application binaries is to the folder containing the application PDB files.
Note |
---|
Multiuser coverage is not currently available for standalone applications. |
Anchor | ||||
---|---|---|---|---|
|
...