Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

When executing Tests via gradle you do not need to provide the buildSessionId generated in a previous step via an environment variable or a text file.

Please make sure the Sealights Test Listener is deployed to capture coverage of the application to be tested by this script.

For Java application, you can refer to Using Java Agents - Installing Test Listener as Java Agent

Configuring Gradle plugin in build.gradle

In the repositories dependencies section add:

  1. classpath 'io.sealights.on-premise.agents.plugin:sealights-gradle-plugin:latest.release'

In the allprojects section add the following:

  1. apply plugin: 'io.sealights.on-premise.agents.plugin.sealights-gradle-plugin'

  2. sealights section with the following parameters

    1. token or tokenFile - set with a token or a file containing the token obtained from the SeaLights dashboard

    2. buildSessionId or buildSessionIdFile - Set with a build session id or a file containing the build session id created externally via the config step, by the config step

    3. createBuildSessionId - Set to false

    4. filesStorage - location of temporary folder location to store cached agent files

    5. runTestOnly - Set to true if you want to only run tests without scanning builds


The following optional parameters:

  1. logEnabled - Set to true if you want a log to be created

  2. logLevel - Set the log level to create. For example INFO

  3. logToFile - Set to true if you want the log to written to a file

  4. logToConsole - Set to true if you want the log to written to the console

  5. proxy - Provide the URL to the proxy to route the calls through if needed

  6. testListenerJvmParams - Containing and array of all the parameters you want to pass to all the SeaLights test execution step, Note: the key and values must always be strings

  7. testTasks - The list of tasks to integrate SeaLights into the jvmargs in. Default are test, unitPlatformTest & integrationTest

  8. testStage - Provide the name of the test stage you want to report on in the SeaLights dashboard. Default stage name is 'Unit Tests'.

When using gradle on Windows, you will need to double the backslash used in path file for parameters like tokenFile, buildSessionIdFile and fileStorage - i.e. tokenFile = "C:\\Sealights\\sltoken.txt"

In the following example, the steps needed are surrounded by an if condition which allows you to only use Sealights when you pass the -Psealights property when running the gradle build.

  • Without this condition and property, Sealights integration will always be applied and used.

buildscript {
    repositories {
        mavenCentral()
        dependencies {
            if(project.hasProperty('sealights')){
	            classpath 'io.sealights.on-premise.agents.plugin:sealights-gradle-plugin:latest.release'
			}
		}
    }
}

allprojects { p ->
    if(project.hasProperty('sealights')){
        apply plugin: 'io.sealights.on-premise.agents.plugin.sealights-gradle-plugin'
        sealights {
            tokenFile = "./sltoken.txt" 
            createBuildSessionId = false
            buildSessionIdFile = "./buildSessionId.txt"
//          buildSessionId = System.getenv('SL_BUILD_SESSION_ID')

            testStage = "Functional Tests"
       	    filesStorage="/tmp"
            logEnabled = false
            logLevel = "WARN"
            logToFile = false
            logToConsole = true
            
            runTestOnly=true
            testTasks=["test"]
//          proxy = "http://localhost:8888"
//          testListenerJvmParams=["sl.param1":"true","sl.param2":"value"]
        }
    }
}

JUnit 5

When using JUnit 5 you need to notify the SeaLights agent that this is the case. You do so by passing sl.junitVersion=5 to the sealightsJvmParams

sealightsJvmParams=["sl.junitVersion":"5"]


  • No labels