Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Table of Contents

Gathering coverage and test information using the SeaLights Java Test Listener is done in a few steps, we recommend to use the Lab ID for this. If your component does not yet support the Lab ID option, use the Build Session ID to connect between the test listener and the test runner

...

When working with a supported framework , - for example, JUnit or TestNG , - you can add the Sealights test listener as a javaagent which will capture Java agent that automatically captures the test information automatically.

Code Block
languagebash

...

export SEALIGHTS_OPTS="-javaagent:/path/to/sl-test-listener.jar -Dsl.tags=testNG -tokenfile -

...

Dsl.tokenFile=/path/to/sltoken.txt -Dsl.labid <Lab ID> -Dsl.testStage \"Functional Tests\" "
java $SEALIGHTS_OPTS -cp <CLASSPATH> org.testng.TestNG -testclass com.my.test

In the sample command above, the javaagent is declared via a dedicated SEALIGHTS_OPTS environment variable, but you can also declare it 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.

Expand
titleUsing Build Session ID

If the BuildSessionId needs to be passed explicitly, you should use a command similar to the one below

Code Block
languagebash

...

export SEALIGHTS_OPTS="-javaagent:/path/to/sl-test-listener.jar -Dsl.tags=testNG -tokenfile -Dsl.tokenFile=/path/to/sltoken.txt -Dsl.buildSessionIdFile=buildSessionId.txt -Dsl.labid <Lab ID> -Dsl.testStage \"Functional Tests\" "
java $SEALIGHTS_OPTS -cp <CLASSPATH> org.testng.TestNG -testclass com.my.test
Info

See 'Java Command Reference - Installing test listener as Java Agent' for full parameter details

Working without a supported framework

...