API Tests
This page walks you through Drill4J integration for Java-based API tests. It will enable you to use such features as Per Test Coverage and Test Recommendations
#
PrerequisitesThis page assumes you have Application Agent configured for application under test. For instructions see:
API tests launched with either Maven or Gradle
This instruction involves making changes to the Gradle/Maven project build file.
#
Install Drill4J PluginThe Drill4J CI/CD integration plugin allows you to run API tests together with the Test Agent. Add following changes to your Gradle/Maven project with API tests build file to install the Drill4J plugin:
#
Gradleplugins {id("com.epam.drill.integration.cicd") version "0.1.6"}
#
Maven<build><plugins><plugin><groupId>com.epam.drill.integration</groupId><artifactId>drill-maven-plugin</artifactId><version>0.1.6</version><configuration></configuration></plugin></plugins></build>
#
Enable Test AgentTo enable the Test Agent set the plugin configuration:
#
GradleAdd drill
section into the bottom of the Gradle build file:
drill {// Set the Drill4J API URL// or set DRILL_API_URL env variabledrillApiUrl = "http://localhost:8090/api"// Set the Drill4J API Key// or set DRILL_API_KEY env variabledrillApiKey = "1_01cdf51ff20544ee..."// Set the Drill4J Group IDgroupId = "my-group"enableTestAgent {version = "0.23.3"}}
#
MavenAdd <configuration>
and <executions>
elements to Drill4J plugin in your Maven pom.xml file:
<plugin><groupId>com.epam.drill.integration</groupId><artifactId>drill-maven-plugin</artifactId><version>0.1.6</version><configuration><!-- Set the Drill4J API URL --><!-- or set DRILL_API_URL env variable --><apiUrl>http://localhost:8090/api</apiUrl><!-- Set the Drill4J API Key --><!-- or set DRILL_API_KEY env variable --><apiKey>1_01cdf51ff20544ee...</apiKey><!-- Set the Drill4J Group ID --><groupId>my-group</groupId><testAgent><version>0.23.3</version></testAgent></configuration><executions><execution><goals><goal>enableTestAgent</goal></goals></execution></executions></plugin>
#
Run API Tests- Launch your tests with Gradle/Maven (e.g.
gradle test
,mvn test
).
IMPORTANT! When running tests in your IDE, double-check that it's picking up the correct configuration file with the Drill4J test agent added (that will be
build.gradle
for Gradle,pom.xml
for Maven)
To confirm test agent is working check tests log. There should be Drill4J ASCII logo followed by test agent version:
That’s it! Open the Metabase UI and confirm that the new test information is coming through. You should see the Test Launches on the Build Summary dashboard.