Skip to content

Writing Extensions

Andrei Tuicu edited this page Sep 11, 2018 · 2 revisions

Creating the Maven Project

Create a maven project with a starting pom with the following template (You can also find an example project here)

Generic Toughday2 project

<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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>com.adobe.qe</groupId>
        <artifactId>toughday2-tests-parent</artifactId>
        <version>0.9.2</version>  <!-- Always try to use the latest version -->
    </parent>
    <groupId>${YourGroupID}</groupId>
    <artifactId>${YourArtifactID}</artifactId>
    <packaging>jar</packaging>
    <version>${YourVersion}</version>
 
</project>

AEM Specific Tests

<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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
 
    <parent>
        <groupId>com.adobe.qe</groupId>
        <artifactId>aem-td2-tests-parent</artifactId>
        <version>0.9.2</version> <!-- Always try to use the latest version -->
    </parent>
 
    <groupId>${YourGroupID}</groupId>
    <artifactId>${YourArtifactID}</artifactId>
    <packaging>jar</packaging>
    <version>${YourVersion}</version>
 
</project>

CCIF Specific Tests

<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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>com.adobe.cq</groupId>
        <artifactId>cloud-perf-parent</artifactId>
        <version>${ReleaseVersion}</version>  <!-- Always try to use the latest version -->
    </parent>

    <groupId>${YourGroupID}</groupId>
    <artifactId>${YourArtifactID}</artifactId>
    <packaging>jar</packaging>
    <version>${YourVersion}</version>
 
</project>

Then you are good to go to create your first ToughDay2 test.

How to load an extension jar

Extensions are added in the same way we add a test or a publisher (using --add option). So, in order to run a test contained in an extension jar file, we have to add both the extension jar file and the test from that extension. In order to do that, we have two options:

Use command line arguments :

java -jar ToughDay.jar --host=localhost --add pathToJarFile/ExtensionFileName.jar --add ExtensionTestName

Use one yaml configuration file and pass this file to ToughDay using the --configfile option:

java -jar ToughDay.jar --configfile=pathToConfigFile/ConfigFileName.yaml

An example of how extensions should be written inside the configuration file can be found below:

globals:
  port : 4502
  host : localhost
 
extensions:
  - add : /path/to/toughday2-tests-sample-0.1.0-SNAPSHOT.jar
  - add : /path/to/toughday2-publisher-sample-0.1.0-SNAPSHOT.jar
 
tests:
  - add : MyDemoTest
    properties:
      property : demo

publishers:
  - add : com.adobe.qe.example.MyDemoPublisher

What's API and what's not?

ToughDay2 provides a set of API classes which are located in the com.adobe.qe.toughday.api package of the com.adobe.qe:toughday2-api jar. Toughday2 developers will strive to keep these API classes backwards compatible moving forward, but until the 1.0.0 version is released this is not guaranteed. Any other classes (usually located in packages marked as *.internal.*, but not necessarily) are subject to change without prior notice.

Moving forward, most likely more internal classes will move to the API package to allow more OOTB functionality or to provide more extension points.

What are the existing Extension Points?

Currently, the following extension points are provided by the Toughday2 core: