Skip to content

Context Menu Plugin

Itai Agmon edited this page Sep 4, 2017 · 2 revisions

Context Menu Plugin

@since version 6.1.06

You can enhance JSystem and add functionality to the scenario context menu. The context menu is shown when the user is right clicking on one of the elements in the scenario tree (In the left side of the JSystem application).

This can be useful for integrating with external systems like test management systems or to add new capabilities like pause before running a building block.

Creating context menu plugin

To create a new plugin, create a new Maven project and add the jsystemApp as dependency in the project POM file.

POM file example:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<groupId>org.jsystemtest</groupId>
	<artifactId>my-awesome-plugin</artifactId>
	<version>0.0.1-SNAPSHOT</version>

	<properties>
		<maven.compiler.source>1.7</maven.compiler.source>
		<maven.compiler.target>1.7</maven.compiler.target>
		<topq.repository.rootUrl>http://maven.top-q.co.il</topq.repository.rootUrl>
	</properties>

	<dependencies>
		<dependency>
			<groupId>org.jsystemtest</groupId>
			<artifactId>jsystemApp</artifactId>
			<version>6.1.06</version>
                        <scope>provided</scope>
		</dependency>
	</dependencies>
	<repositories>
		<repository>
			<id>topq</id>
			<url>${topq.repository.rootUrl}/content/groups/public</url>
		</repository>
	</repositories>
</project>

Implementing the plugin

In the project create a new class and implement the ContextMenuPlugin. You will be required to implement three methods.

The method void init(TestsTableController testsTableController) will be called on JSystem launch. The testsTableController object is the object that represents the scenario tree and it allows you to read different statuses from the tree and change it.

The method boolean shouldDisplayed(ScenarioTreeNode currentNode, TestsContainer container, JTest test) will be called each time the user is right clicking on one of the elements of the tree. You should return boolean value that will signal if JSystem should use your plugin on this specific node.

String getItemName() This is the actual text that should appear in the context menu.

ImageIcon getIcon() The icon that should appear in the context menu when the plugin is enabled.

Adding the plugin to JSystem

To add the plugin to JSystem, build your plugin project and copy the plugin jar file and all the required dependencies to the runner thirdpary/commonLib folder. If you decide that the plugin should be part of your automation project, this step is not necessary.

Open the jsystem.properties file for edit and add or update the context.menu.plugin.classes property with the full name of your plugin class.

For example:

context.menu.plugin.classes=org.jsystemtest.MyAwesomePlugin

Notice: You can also set this property from the jsystem properties dialog.

Usage

Restart JSystem if needed and right click on the scenario tree to see your new plugin.

An example for such plugin can be found here.

Clone this wiki locally