Skip to content

wavesoftware/java-gasper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Gasper!

Build Status Coverage Status

Gasper is a very simple integration testing JUnit harness for java -jar servers like WildFly Swarm and Spring Boot.

WildFly Swarm 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.

Usage

Best to use with libraries like Unirest and JSON Assert

WildFly Swarm configuration

@ClassRule
public static Gasper gasper = Gasper.configurations()
  .wildflySwarm()
  .build();

Spring Boot configuration

@ClassRule
public static Gasper gasper = Gasper.configurations()
  .springBoot()
  .build();

Example test method (Unirest + JSONAssert)

@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);
}

Addtional configuration

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();

Installation

Maven

<dependency>
    <groupId>pl.wavesoftware</groupId>
    <artifactId>gasper</artifactId>
    <version>1.0.0</version>
    <scope>test</scope>
</dependency>

Gradle

testCompile 'pl.wavesoftware:gasper:1.0.0'

Requirements

Gasper requires Java 8. Tested on Travis CI.

About

Very simple integration testing JUnit harness for 'java -jar' servers like WildFly Swarm and Spring Boot

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  

Languages