Gasper

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

Лицензия

Лицензия

Группа

Группа

pl.wavesoftware
Идентификатор

Идентификатор

gasper
Последняя версия

Последняя версия

1.0.0
Дата

Дата

Тип

Тип

jar
Описание

Описание

Gasper
Very simple integration testing JUnit harness for 'java -jar' servers like WildFly Swarm and Spring Boot
Ссылка на сайт

Ссылка на сайт

http://wavesoftware.github.io/java-gasper/
Организация-разработчик

Организация-разработчик

Wave Software
Система контроля версий

Система контроля версий

https://github.com/wavesoftware/java-gasper

Скачать gasper

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/pl.wavesoftware/gasper/ -->
<dependency>
    <groupId>pl.wavesoftware</groupId>
    <artifactId>gasper</artifactId>
    <version>1.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/pl.wavesoftware/gasper/
implementation 'pl.wavesoftware:gasper:1.0.0'
// https://jarcasting.com/artifacts/pl.wavesoftware/gasper/
implementation ("pl.wavesoftware:gasper:1.0.0")
'pl.wavesoftware:gasper:jar:1.0.0'
<dependency org="pl.wavesoftware" name="gasper" rev="1.0.0">
  <artifact name="gasper" type="jar" />
</dependency>
@Grapes(
@Grab(group='pl.wavesoftware', module='gasper', version='1.0.0')
)
libraryDependencies += "pl.wavesoftware" % "gasper" % "1.0.0"
[pl.wavesoftware/gasper "1.0.0"]

Зависимости

compile (7)

Идентификатор библиотеки Тип Версия
junit : junit jar 4.12
com.mashape.unirest : unirest-java jar 1.4.7
pl.wavesoftware : eid-exceptions jar 1.1.0
org.slf4j : slf4j-api jar 1.7.18
com.google.guava : guava jar 19.0
org.apache.maven : maven-model jar 3.0.4
org.apache.maven : maven-core jar 3.0.4

provided (1)

Идентификатор библиотеки Тип Версия
org.projectlombok : lombok jar 1.16.6

test (3)

Идентификатор библиотеки Тип Версия
org.mockito : mockito-core jar 2.0.43-beta
org.assertj : assertj-core jar 3.3.0
org.slf4j : slf4j-simple jar 1.6.6

Модули Проекта

Данный проект не имеет модулей.

Gasper!

Build Status Coverage Status Codacy Badge SonarQube Quality Gate SonarQube Tech Debt Maven Central Join the chat at https://gitter.im/wavesoftware/java-gasper

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 REST micro-services. You can configure Gasper easily with a builder interface. Gasper will start the application before test class and stop it after tests completes.

Gasper supports currently only Maven. The pom.xml file is used to read project configuration achieving zero configuration operation.

Usage

Gasper utilize your packaged application. It It means it should be used in integration tests that run after application is being packaged by build tool (Maven). Add this code to your pom.xml file (if you didn't done that before):

<build>
[..]
<plugins>
[..]
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-failsafe-plugin</artifactId>
    <version>2.19.1</version>
    <executions>
      <execution>
        <goals>
          <goal>integration-test</goal>
          <goal>verify</goal>
        </goals>
      </execution>
    </executions>
  </plugin>
[..]
</plugins>
[..]
</build>

Place your integration tests in classes that ends with *IT or *ITest.

WildFly Swarm configuration

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

Spring Boot configuration

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

Before running GasperBuilder.build() method, you can reconfigure those default configurations to your needs.

Example test method (Unirest + JSONAssert)

Gasper is best to use with libraries like Unirest for fetching data and asserting HTTP/S statuses and JSON Assert to validate correctness of JSON output for REST services.

@Test
public void testGetRoot() throws UnirestException {
  // given
  String address = gasper.getAddress(); // Address to deployed app, running live on random port
  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); // JSON Assert
}

Additional configuration

To configure Gasper use GasperBuilder interface, for ex.:

private final int port = 11909;
private final String webContext = "/test";
private final String systemPropertyForPort = "swarm.http.port";

@ClassRule
public static Gasper gasper = Gasper.configure()
  .silentGasperMessages()
  .usingSystemPropertyForPort(systemPropertyForPort)
  .withSystemProperty("swarm.context.path", webContext)
  .withSystemProperty(systemPropertyForPort, String.valueOf(port))
  .withJVMOptions("-server", "-Xms1G", "-Xmx1G", "-XX:+UseConcMarkSweepGC")
  .withMaxStartupTime(100)
  .withMaxDeploymentTime(20)
  .withEnvironmentVariable("jdbc.password", "S3CreT!1")
  .withTestApplicationLoggingOnConsole()
  .usingPomFile(Paths.get("pom.xml"))
  .withArtifactPackaging("jar")
  .waitForWebContext(webContext)
  .withArtifactClassifier("swarm")
  .usingWebContextChecker(GasperBuilderTest::checkContext)
  .withPort(port)
  .build();

Installation

Maven

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

Contributing

Contributions are welcome!

To contribute, follow the standard git flow of:

  1. Fork it
  2. Create your feature branch (git checkout -b feature/my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin feature/my-new-feature)
  5. Create new Pull Request

Even if you can't contribute code, if you have an idea for an improvement please open an issue.

Requirements

  • Java 8
  • Maven 3

Releases

  • 1.0.0 - codename: SkyMango
    • First publicly available release
pl.wavesoftware

Wave Software

Версии библиотеки

Версия
1.0.0