Test Agent
The Drill4J Test Agent allows you to map tests to code coverage and vice versa. Key Features:
- Test context propagation
- Control over test execution
General integration steps are:
Due to the diverse tools used in software development — such as CI/CD providers, deployment methods, testing stages — the exact process will depend on the environment.
#
How to download#
Download agent files manuallyNote: This is not the most convenient way to get agent files. If you are using Maven or Gradle, there is a primary way, see next section.
The most basic way to get agent files is to download release .zip manually.
Download release appropriate for your platform at https://github.com/Drill4J/autotest-agent/releases/tag/v0.23.1.
mingwX64
is for Windows, Linux and Mac releases are called respectively.Unzip the file. Rename unzipped folder to
agent
.Inside you'll find the following files:
libdrill_agent.so
(on Windows -.dll
, on Mac -.dylib
)drill-runtime.jar
drill.properties
Refer to next section for further steps.
#
Use Drill4J CI/CD Integration Plugin for Maven and GradleUse cases: when application (or certain classes of application) is launched with Maven or Gradle. That's most often the case with Unit tests.
Drill4J CI/CD Integration Plugin automatically downloads agent files and passes required parameters to Java when running tests.
Because of that, the next sections of this page are irrelevant in this scenario. Instead, please refer to CI/CD Integration Plugin page for more info.
#
How to set path to agent when running testsTest agent use -agentpath JVM command line argument to loading when starting java process.
In order to pass -agentpath
command-line argument when running tests, you can configure the argLine for Maven
or jvmArgs for Gradle parameters.
There are two way to pass -agentpath
parameter:
- In command line for running tests
- Inside the build configuration file
-agentpath
in command line for running tests#
Pass #
GradleAdd -DjvmArgs
parameter to gradle command line:
#
MavenAdd -DargLine
parameter to Maven command line:
-agentpath
in the build configuration file#
Set #
GradleAdd jvmArgs
to Gradle test configuration:
#
MavenAdd argLine
to maven-surefire-plugin
in pom.xml:
#
How to set agent parametersDrill4J Test Agent has the same ways to set agent parameters that Application Agent. To know how to use it see the Application Agent reference.
#
Agent parameters referenceParameter | Required | Example Value | Description |
---|---|---|---|
apiUrl | yes | http://localhost/api | URL to Drill4J Admin /api endpoint. |
apiKey | yes | 1_01cdf51ff20544ee... | Drill4J Backend API key. Generate it using Drill4J UI. Please make sure to read the apiKey security section |
groupId | yes | my-cool-app | Unique arbitrary string identifying your application group. |
withJsCoverage | no | true | Enables collecting JS coverage by Chrome DevTools |
devToolsProxyAddress | no | http://localhost:8092 | URL address of Drill4J DevToolsProxy |
#
API key security❗ Please avoid hardcoding apiKey and exposing it in plain text. Instead, use environment variables. ❗
Bad example:
Good example:
#
Troubleshooting#
How to confirm agent is loadedOnce loaded Drill4J agent prints the following ASCII logo:
It indicates that you have configured agent path correctly and Java picked up and loaded agent files.
#
Cannot load the agent because some agent parameters are set incorrectlyIf below Drill4J ASCII logo you see the following message:
It indicates that you are missing some required parameters. Refer to the agent parameters section.
#
Error "Could not create an Appender of type ..."The following error can be safely ignored as it doesn’t impact the functionality of the application or agent. It simply indicates that Logback is being used with a logback.xml file, which conflicts with the Drill4J logging configuration. However, logging will still function as expected.
#
Limitations and Known Issues- The Drill4J is not compatible with the JaCoCo code coverage tool. JaCoCo conflicts with the Drill4J Test Agent and Application Agent, so it needs to be removed. This should’t be a concern, as Drill4J includes the same functionality along with additional features.