Maven
Overview
This guide covers how to integrate Sealights into your tests running in Maven. You can use the SeaLights agent to update your Maven's pom.xml with the needed changes to run your Maven tests using the Sealights Maven Plugin
Prerequisites
Verify that the environment of the application under test and the machine(s) that run the test have connectivity to Sealights Cloud. See the how to verify connectivity guide for more information.
Installing Sealights requires modifying your application components' deployment scripts and possibly the CI Job that runs your tests. Please verify you have the necessary permissions in your organization.
Setup
TL;DR: You can jump directly to the Sample script section below.
Download the Sealights Agent
Download the Sealights Agent form: https://agents.sealights.co/sealights-java/sealights-java-latest.zip and place it in your workspace where your Maven project is located.
You can use the following commands to automate the process in the environment setup script
Create a JSON configuration file
Create a JSON configuration file with the following parameters in order to provide the necessary configuration fields to the SeaLights Maven plugin:
Parameter | Value | Remarks |
---|---|---|
tokenFile | set with the relative or absolute path to a file containing the agent token obtained from the SeaLights dashboard. | This can be either the same or a different valid token than the one used with the agent attached to your application under test. |
createBuildSessionId | False | |
executionType | testsonly | Provide which executions need to be handled by the Maven plugin. In our case, testsonly to capture only the tests execution and not the project compilation. |
<Test Stage Name> | Set the name of the test stage as will be displayed on the SeaLights dashboard. For example, "Regression Tests", "Selenium Tests" or "Functional Tests". | |
labId | <Lab ID> | Unique Identifier of the testing environment where the Sealights agent is attached and that was defined in the Settings |
runFunctionalTests | true | for Testing projects using Sealights Maven plugin |
As a result, your JSON configuration file should look like this:
In the file above, you need to make sure the following lines are specific to your environment and configuration:
line 2: path to the token file,
line 5: Name the stage as you want to see it in your Sealights Dashboard,
line 6: Lab ID you have defined in your settings and provided to your Coverage agent
line 9: If required, proxy details.
Name this file with a convenient name (slmaventest.json
for example) and place it in your Project workspace for the next steps below.
Integrate Sealights dynamically into the Maven project
Before running your Maven command, you'll run Sealights Advanced agent with the -pom
flag to add the SeaLights Maven Plugin into your project configuration. This command will use the JSON configuration file defined above to inject Sealights plugin integration into the pom.xml settings.
The parameters it receives are:
configfile - The path to the JSON configuration you created with the parameters to be provided to the SeaLights Maven Plugin
workspacepath - The base path to the location of the pom.xml files to update
At the successful completion of the command, you’ll see the following last line in the console:
[Sealights Build Scanner] - Pom integration was completed.
This step will update all the pom.xml files and back them up to pom.xml.slback copies in the same directory
If your workspace is not reset for each build, you will need to restore them at the end of the run (see command below).
Execute your tests
You can use your regular maven command to execute your tests. Typically, the command is 'mvn clean install' or 'maven clean verify' for example.
Sample script
Make sure to update the token value on line 7 and labId on line 16 before running this sample. These values need to be aligned with your specific configuration and account settings.
Optional
Restore your Maven configuration to its previous state
In case the pom file is to be restored to its previous state before the Sealights plugin was applied, use the build scanner with the -restorePom
flag on the workspace where the pom.xml file is located:
Last updated