Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

...

...

...

Table of Contents

Creating a Session ID

Before running the build scan and tests, you need to create a session ID. The session ID is provided to each step in order to link them together as one complete cycle.

Generating a session ID in Java is done using the Java Build scanner with the -config flag. This command can be executed as an ANT Java task.In the following sample, we have used a timestamp for the build name but any environment variable can be used according to your organization’s naming convention.

Code Block
languagexml
<tstamp>
     <format property="time.stamp" pattern="yyyyMMdd-HHmm"/>
</tstamp>

<target name="sealights_config">
	<java jar="${sealights.dir}/sl-build-scanner.jar" fork="true">
		<arg value="-config"/>
		<arg value="-tokenfile"/>
		<arg value="${sealights.dir}/sltoken.txt"/>
		<arg value="-appname"/>
		<arg value="myApp"/>
		<arg value="-branchname"/>
		<arg value="master"/>
		<arg value="-buildname"/>
		<arg value="${time.stamp}"/>
		<arg value="-pi"/>
		<arg value="*com.company.*"/>
	</java>
</target>

In the sample code above, we have used a timestamp for the build name but any environment variable can be used according to your organization’s naming convention.

Info

See 'Java Command Reference - Creating a session ID' for full parameter details

...

JUnit 4.x

JUnit 5.x

Code Block
languagexml
<junit fork="yes">
  <jvmarg value="-javaagent:${sealights.dir}/sl-test-listener.jar"/>
  <jvmarg value="-Dsl.tokenFile=${sealights.dir}/sltoken.txt"/>
  <jvmarg value="-Dsl.buildSessionIdFile=buildSessionId.txt"/>
  <jvmarg value="-Dsl.testStage=Unit Tests"/>
</junit>
Code Block
languagexml
<junitlauncher>
            <testclasses outputdir="build/test-report">
                 <fork>
                    <jvmarg value="-javaagent:${sealights.dir}/sl-test-listener.jar"/>
                    <jvmarg value="-Dsl.tokenFile=${sealights.dir}/sltoken.txt"/>
                    <jvmarg value="-Dsl.buildSessionIdFile=buildSessionId.txt"/>
                    <jvmarg value="-Dsl.testStage=Unit Tests"/>
                </fork>
            ...
</junitlauncher>
Info

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

Sample integration into an existing ANT project

...

Here is a comparison of executions with and without the sealigths parameter set to true.

...