Using Supported Test Frameworks
Capturing Coverage Using Supported Test Frameworks
You can add the agent in one of the following ways:
Inline — Add the
-javaagentand parameters directly to yourjava -jarcommand used to run your testsEnvironment variables — Set the parameters via
JAVA_TOOL_OPTIONSor a similar JVM variable
Implementation Steps
Download the SeaLights Java Agent
The SeaLights Java Agent will need to be available on the machine where you build your test runner and/or run your tests.
Download the latest version of the SeaLights Java Agent.
There are two agent files
Build Scanner - sl-build-scanner.jar
Test Listener - sl-test-listener.jar
These agent files can be downloaded from: https://agents.sealights.co/sealights-java/sealights-java-latest.zip
Example CLI commands for downloading the SeaLights Java Agent:
# Download the latest Java agent
wget -nv https://agents.sealights.co/sealights-java/sealights-java-latest.zip
# Extract the agent
unzip -oq sealights-java-latest.zip
#validate the agent version
echo "Sealights Java Agent version used is:" `cat sealights-java-version.txt`Run Your Test Runner with the SeaLights Java Agent
When using a supported framework (such as JUnit or TestNG), attach the SeaLights Java Test Listener agent as a -javaagent to your test runner. This allows SeaLights to automatically associate each test execution with its code coverage.
You can add the SeaLights Java Agent in one of the following ways:
Inline — Add the
-javaagentand parameters directly to yourjava -jarcommand used to run your componentJVM Environment Variable — Set the parameters via
JAVA_TOOL_OPTIONSor a similar JVM variable
Example 1: Adding the SeaLights Agent and parameters to your java command inline
java -javaagent:/path/to/sl-test-listener.jar \
-Dsl.tokenFile=/path/to/agent/tokenfile \
-Dsl.labid=<test-env-id> \
-Dsl.testStage="Functional Tests" \
-cp $CLASSPATH org.testng.TestNG -testclass com.my.testOr, the same approach, using a dedicated environment variable to inject the SeaLights Agent options into the command:
export SEALIGHTS_OPTS="-javaagent:/path/to/sl-test-listener.jar -Dsl.tokenFile=/path/to/sltoken.txt -Dsl.labid=<test-env-id> -Dsl.testStage=\"Functional Tests\" "
java $SEALIGHTS_OPTS -cp <CLASSPATH> org.testng.TestNG -testclass com.my.testExample 2: Using JAVA_TOOL_OPTIONS
In this example, we declare the javaagent via standard JVM variables, like JAVA_OPTS or JAVA_TOOL_OPTIONS for example. This is useful for testing frameworks like Cucumber for Java, which relies on JUnit or TestNG behind the scenes.
export JAVA_TOOL_OPTIONS=-javaagent:/path/to/sl-test-listener.jar -Dsl.tokenFile=/path/to/agent/tokenfile -Dsl.labid=<test-env-id> -Dsl.testStage="Functional Tests"Minimum Required Parameters
sl.tokenFile- Path to the agent token filesl.labid- A unique name representing the environment in which your AUT was deployed (and against which you are testing). This MUST match the Lab ID from Phase 1.sl.testStage- A label for the type of tests being run (e.g., "Functional Tests", "Integration Tests", "E2E Tests"). This will be used when displaying the coverage data in your SeaLights reports.
Additional optional parameters may be found here: Java Agent Configuration Parameters
What Happens When Your Test Runner Starts?
The SeaLights agent rides along with your test runner to send metadata about the tests you're running to the SeaLights Backend. After your test execution is completed, SeaLights will automatically show you the percentage of code covered by this test run.
Verification
To confirm Phase 2 was successful:
Check the console output — Look for messages confirming successful agent startup.
Visit the SeaLights Dashboard — Verify that:
Your new test stage appears in the dashboard under your component
Coverage data begins appearing under the new test stage
Next Steps
With advanced coverage analytics in place, you're ready to move on to Phase 3: Continuous Coverage. In Phase 3, you'll integrate SeaLights into your CI pipeline for continuous, up-to-date visibility into build coverage.
Last updated
Was this helpful?

