ct-jsrt-test-maven-plugin

The ct-jsrt-test-maven-plugin provides a goal to execute the test frameworks inside PhantomJS .

To run the tests in a CI Server, each of the test frameworks provided by map.apps has support for a special script, which is included in the maven plugin. This section describes the configuration properties.

This plugin loads the runner.html pages inside the headless browser provided by PhantomJS. PhantomJS is based on Chromium so the tests are executed like running in the Chrome browser.

Goals

help

Display help for the ct-jsrt-test-maven-plugin.

> mvn de.conterra.jsrt:ct-jsrt-test-maven-plugin:<version>:help -Ddetail=true

Set the <version> to your current ct-jsrt-test version, for example 1.0.0

Parameter Default Description

detail

false

If true, display all settable properties for each goal.

goal

-

The name of the goal for which to show help. If unspecified, all goals are displayed.

indentSize

2

The number of spaces per indentation level, should be positive.

lineLength

80

The maximum length of a display line, should be positive.

runTests

Executes PhantomJS and load the test pages.

Binds by default to test lifecycle.

runTests Sample
<plugin>
    <groupId>de.conterra.jsrt</groupId>
    <artifactId>ct-jsrt-test-maven-plugin</artifactId>
    <executions>
        <execution>
            <phase>test</phase>
            <goals>
                <goal>runTests</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <!-- wait a bit to let the server fully start up -->
        <initialDelay>2000</initialDelay>
        <!-- test execution should not be longer as 1 minute -->
        <timeout>60000</timeout>
        <!-- which test URL should be loaded -->
        <tests>
            <test>http://localhost:8080/resources/jsregistry/root/doh/1.9.1/runner.html?test=helloworld/tests/doh-all</test>
            <test>http://localhost:8080/resources/jsregistry/root/intern-geezer/1.7.0/runner.html?test=helloworld/tests/intern-all</test>
        </tests>
    </configuration>
</plugin>
Parameter Default Description

tests

-

A list of tests, pointing to URLs which run unit tests (runner.html).

initialDelay

5000

The time to wait before starting the first test.

timeout

60000

The maximal time to wait until a result is expected from the test page.

phantomJsBinary

-

The path to phantom js binary. Binary for Windows and Linux are included in the plugin.

Example

A typical usage in a map.apps project is the combination with an automatic start of the jetty server:

run-js-tests profile
<profile>
    <id>run-js-tests</id>
    <build>
        <plugins>
            <plugin>
                <groupId>org.eclipse.jetty</groupId>
                <artifactId>jetty-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>jetty-start</id>
                        <phase>process-test-classes</phase>
                        <goals>
                            <goal>start</goal>
                        </goals>
                        <configuration>
                            <scanIntervalSeconds>0</scanIntervalSeconds>
                            <daemon>true</daemon>
                        </configuration>
                    </execution>
                    <execution>
                        <id>jetty-stop</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>stop</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>de.conterra.jsrt</groupId>
                <artifactId>ct-jsrt-test-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>test</phase>
                        <goals>
                            <goal>runTests</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <tests>
                        <test>http://localhost:8080/resources/jsregistry/root/intern-geezer/1.7.0/runner.html?test=helloworld/tests/intern-all</test>
                    </tests>
                </configuration>
            </plugin>
        </plugins>
    </build>
</profile>

The Maven command line is:

> mvn package -P run-js-tests