JSystem Maven Plugin

JSystem Maven Plugin

The most common way of executing JSystem scenarios is from the runner GUI. But in some case, we would like to execute scenarios directly from the command line without opening any graphic interface. This method can be easier for integrating JSystem with CI systems and would result less resource consumption.

Running scenarios from the command line can be done by using the runScenario batch/shell scripts that are included in the JSystem root folder. JSystem 6.0.00 introduces another way for Maven based projects; Executing scenarios using the JSystem Maven plugin.

The main benefit of the JSystem Maven plugin is that there is no need for JSystem installation. The execution is done by using the JSystem jars that are already included as dependencies in the project.

Configuring the Plugin

If you were using JSystem archetypes for creating your automation project as described in the Getting Started Guide you already have the plugin configured in your test project pom.xml file. Open the test project and search for the plugin definition.

 

<plugin>
	<groupId>org.jsystemtest</groupId>
	<artifactId>jsystem-maven-plugin</artifactId>
	<version>6.0.02</version>
	<dependencies>
		<dependency>
			<groupId>org.jsystem</groupId>
			<artifactId>my-tests-proj</artifactId>
			<version>[0.0,]</version>
			<scope>runtime</scope>
		</dependency>
	</dependencies>
</plugin>

Since Maven plugins are using a separate class loader then the project, we need to add the project artifact as a dependence to the plugin. In the project generation process the test project GAV details were already updated. Notice, that in the version section there is a use in the Maven version range specification for specifying the latest project version.

Executing the Plugin

The plugin can be executed from the command line. Change directory to the test project’s root folder and call to the run goal of the jsystem-maven-plugin

> mvn jsystem:run -Dscenario=scenarios/default -Dsut=default.xml

The goal receives two arguments; The scenario name and the sut file name.

Notice that the HTML and other reports are all generated in the log/current folder under the project’s root directory.

Running from POM

You can also configure the plugin from the POM and attach it to one of Maven goals lifecycle phases.

<plugin>
	<groupId>org.jsystemtest</groupId>
	<artifactId>jsystem-maven-plugin</artifactId>
	<version>6.0.02</version>
	<executions>
		<execution>
			<phase>integration-test</phase>
			<goals>
				<goal>run</goal>	
			</goals>
			<id>runScenario</id>
			<configuration>
				<sut>default.xml</sut>
				<scenario>scenarios/default</scenario>
			</configuration>	
		</execution>
	</executions>
	<dependencies>
		<dependency>
			<groupId>org.jsystem</groupId>
			<artifactId>my-tests-proj</artifactId>
			<version>[0.0,]</version>
			<scope>runtime</scope>
		</dependency>
	</dependencies>
</plugin>

In this example, in the integration-test phase the default scenario is executed using the default.xml sut.

Executing Multiple Scenarios

From version 6.0.03 the JSystem Maven plugin supports execution of multiple scenarios. To specify more than one scenario, list all the scenarios you wish to execute separated by a comma. You would also need to specify the SUT files in the same fashion.

>mvn jsystem:run -Dscenario=scenarios/s1,scenarios/s2 -Dsut=sut1.xml,sut2.xml

NOTICE: The number of scenario must be equals to the number of sut files

If you were using JSystem ‘Multiple Scenario Execution’ feature, you may already have an XML file with sequences of scenarios and sut files. You can still use those XML files with the JSystem Maven plugin. Just use the -DxmlFile switch to specify the location of the XML file.

>mvn jsystem:run -DxmlFile=myXmlFile.xml

 

Debugging

If you are using Eclipse you can easily debug the scenario. From Eclipse menu open ‘Run’->’Debug Configuration’  and a new Maven Configuration with your project as Base Directory and the plugin configuration as goal.

jsystem:run -Dscenario=scenarios/default -Dsut=default.xml

Run Scenario Configuration

View Itai Agmon's LinkedIn profileView Itai Agmon’s profile

Fork me on GitHub