JETTA stands for JUnit Extension for Testcontainers & IntelliJ HTTP Client.
This library aims to make it easy to run API tests written with the IntelliJ HTTP Client inside JUnit 5, orchestrated
with Testcontainers. It is a Java 24–based library and is designed to be published via GitHub Packages. Jetbrains
published a nice blog post
on how to use their IntelliJ HTTP client.
This repository contains the
jetta-coreartifact.GroupId: nl.janboonen.jetta
ArtifactId: jetta-core
To use this extension, you will need to have a correctly working Container Runtime. Please refer to the Testcontainers documentation for details on how to set up your specific environment.
Add the GitHub Packages repository and the dependency.
<repositories>
<repository>
<id>github</id>
<name>GitHub Packages</name>
<url>https://maven.pkg.github.com/boonen/jetta</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>nl.janboonen.jetta</groupId>
<artifactId>jetta-core</artifactId>
<version>0.1.0</version>
</dependency>
</dependencies>In your Maven project, add an integration test class under src/test/java:
package nl.janboonen.jetta.test;
import nl.janboonen.labs.test.IntellijHttpClientFile;
import nl.janboonen.labs.test.IntellijHttpClientTestSupport;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.server.LocalServerPort;
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@IntellijHttpClientFile(value = "src/test/http/ascii.http")
public class SampleIT extends IntellijHttpClientTestSupport {
@LocalServerPort
private int port;
@Override
protected int getPort() {
return port;
}
}There are four things to note:
- Configuration is defined using the
@IntellijHttpClientFileannotation. Thevalueproperty is required and should point to your HTTP Client file. The path is relative to the root of your Maven project. - The test class must extend
IntellijHttpClientTestSupport, which automatically bootstraps the IntelliJ HTTP Client using their official Docker image. - The
getPort()method must be overridden to return the port on which your application. If you use Spring Boot's testing support like in this example, you can use the@LocalServerPortannotation to inject the port. - The application containg the API to be tested must be started before the tests run. In this example we used
@SpringBootTestto start the application at a random port.
If your test executes correctly, then the JUnit5 integration will generate a test report for each Client Test that is defined in the specified IntelliJ HTTP Client file. For more information on how to write Client Tests, please refer to Jetbrains' IntelliJ documentation.
The src/test/resources/ijhttp directory contains an example HTTP Client file that you can use to draw inspiration from.
Requirements: Java 24 and Maven 3.9+
# CI-friendly version defaults:
# revision=0.1.0, changelist=-SNAPSHOT
mvn -B -U verifyTo build a release locally using CI-friendly versions:
mvn -B -Drevision=0.1.0 -Dchangelist= packageIssues and Pull Requests are welcome.
- Issues: Please use the templates (bug report / feature request) and provide minimal reproduction where possible.
- Pull Requests: Keep changes focused. Include tests where applicable. Follow conventional commit messages if you can (e.g. feat: ..., fix: ...).
By contributing, you agree that your contributions are MIT-licensed.