readyapi4j

Swagger Assert4J TestServer Maven Plugin

A maven plugin that runs a set of Json recipes (locally or using a TestServer) and ReadyAPI projects (only with TestServer, not locally) - configure it to run in whatever build phase you might find relevant, for example;

<plugin>
    <groupId>io.swagger.assert</groupId>
    <artifactId>swagger-assert4j-maven-plugin</artifactId>
    <version>1.0.0-SNAPSHOT</version>
    <configuration>
        <username>defaultUser</username>
        <password>defaultPassword</password>
        <server>...Ready!API TestServer endpoint...</server>
    </configuration>
    <executions>
        <execution>
            <id>run</id>
            <phase>integration-test</phase>
            <goals>
                <goal>run</goal>
            </goals>
        </execution>
    </executions>
</plugin>

The only goal exposed by the plugin is “run” - you can invoke it as above or directly from the command-line, for example

mvn testserver:run 

The plugin will look for files with either json or xml extensions.

Configuration

Configuration parameters are:

Specifying a skipApiTests system property will bypass this plugin altogether.

The plugin will also look for standard properties file named recipe.properties in the recipeDirectory folder and load any properties in this file before applying the properties specified in the configuration.

Filtering

Json recipes will be filtered and copied to the folder specified by targetDirectory before getting executed. Any available property will be replaced, which makes it easy to parameterize your tests.

For example the following simple recipe:

{
    "testSteps": [
        {
            "type": "REST Request",
            "method": "GET",
            "URI": "${apitest.host}/apis",
            "assertions": [
                {
                    "type": "Valid HTTP Status Codes",
                    "validStatusCodes": [200]
                }
            ]
        }
    ]
}

would use a property defined as

...
<apitest.host>...</apitest.host>
...

when assembling the URI. You can simply look in the targetDirectory folder after your tests were run to see what was actually executed.

Error reporting

Currently the plugin simple fails the build if any tests fail and dumps the Ready!API TestServer response to the console. A surefire xml file is generated for inclusion in generated reports.

Building the plugin

Simply pull this repo and run

mvn clean install

to install the latest version of the plugin locally. It will eventually be made available on maven central also.