https://github.com/dropwizard/dropwizard-testing-junit6
Dropwizard Test Helpers for JUnit 6
https://github.com/dropwizard/dropwizard-testing-junit6
dropwizard junit junit6
Last synced: 3 months ago
JSON representation
Dropwizard Test Helpers for JUnit 6
- Host: GitHub
- URL: https://github.com/dropwizard/dropwizard-testing-junit6
- Owner: dropwizard
- License: apache-2.0
- Created: 2025-10-05T20:21:22.000Z (7 months ago)
- Default Branch: release/5.0.x
- Last Pushed: 2026-01-12T01:34:03.000Z (3 months ago)
- Last Synced: 2026-01-12T05:56:24.965Z (3 months ago)
- Topics: dropwizard, junit, junit6
- Language: Java
- Homepage: https://www.dropwizard.io/
- Size: 110 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Dropwizard Testing for JUnit 6
This library provides test helpers for [Dropwizard](https://www.dropwizard.io/) applications using [JUnit 6](https://junit.org/junit6/).
## Usage
Add the `dropwizard-testing-junit6` dependency to your `pom.xml`:
```xml
io.dropwizard.modules
dropwizard-testing-junit6
5.0.0-SNAPSHOT
test
```
Then, use the `DropwizardAppExtension` to test your Dropwizard application:
```java
import io.dropwizard.core.Application;
import io.dropwizard.core.Configuration;
import io.dropwizard.core.setup.Environment;
import io.dropwizard.testing.junit6.DropwizardAppExtension;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.client.Client;
import jakarta.ws.rs.core.Response;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import static org.assertj.core.api.Assertions.assertThat;
public class ExampleTest {
@RegisterExtension
public static final DropwizardAppExtension EXTENSION =
new DropwizardAppExtension<>(TestApplication.class, "config.yml");
@Test
void testMyApplication() {
final Client client = EXTENSION.client();
final Response response = client.target(
String.format("http://localhost:%d/my-resource", EXTENSION.getLocalPort()))
.request()
.get();
assertThat(response.getStatus()).isEqualTo(200);
assertThat(response.readEntity(String.class)).isEqualTo("Hello, world!");
}
public static class TestApplication extends Application {
@Override
public void run(TestConfiguration configuration, Environment environment) {
environment.jersey().register(new MyResource());
}
}
public static class TestConfiguration extends Configuration {
}
@Path("/my-resource")
public static class MyResource {
@GET
public String get() {
return "Hello, world!";
}
}
}
```
## License
This project is licensed under the Apache License, Version 2.0. See the [`LICENSE`](LICENSE) file for details.