Gasper is a very simple integration testing JUnit harness for java -jar
servers like WildFly Swarm and Spring Boot.
Gasper provides a simple to use JUnit TestRule
that can be used to build integration tests with simple apps, like microservices. You can configure Gasper with easy to use builder interface.
Best to use with libraries like Unirest and JSON Assert
@ClassRule
public static Gasper gasper = Gasper.configurations()
.wildflySwarm()
.build();
@ClassRule
public static Gasper gasper = Gasper.configurations()
.springBoot()
.build();
@Test
public void testGetRoot() throws UnirestException {
// given
String address = gasper.getAddress();
String expectedMessage = "WildFly Swarm!";
// when
HttpResponse<String> response = Unirest.get(address).asString();
// then
assertThat(response.getStatus()).isEqualTo(200);
assertThat(response.getBody()).field("hello").isEqualTo(expectedMessage);
}
To configure Gasper use GasperBuilder
interface, for ex.:
@ClassRule
public static Gasper gasper = Gasper.configurations()
.wildflySwarm()
.usePomFile(Paths.get("target", "it", "wildfly-swarm-tester", "pom.xml"))
.inheritIO()
.maxStartupTime(120)
.maxDeploymentTime(20)
.useContextChecker(MyTestClass::contextChecker)
.withEnvironmentVariable("jdbc.password", DEV_PASSWORD)
.withJavaOption("my.minus-d.option", "true")
.silent()
.build();
<dependency>
<groupId>pl.wavesoftware</groupId>
<artifactId>gasper</artifactId>
<version>1.0.0</version>
<scope>test</scope>
</dependency>
testCompile 'pl.wavesoftware:gasper:1.0.0'
Gasper requires Java 8. Tested on Travis CI.