https://github.com/MicroShed/microshed-testing
A test framework for black-box testing MicroProfile and Jakarta EE applications
https://github.com/MicroShed/microshed-testing
docker hacktoberfest integration-testing jakartaee java microprofile system-testing testing-framework
Last synced: about 2 months ago
JSON representation
A test framework for black-box testing MicroProfile and Jakarta EE applications
- Host: GitHub
- URL: https://github.com/MicroShed/microshed-testing
- Owner: MicroShed
- License: apache-2.0
- Created: 2019-07-31T14:40:13.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2025-02-20T15:13:19.000Z (about 2 months ago)
- Last Synced: 2025-02-23T23:34:55.520Z (about 2 months ago)
- Topics: docker, hacktoberfest, integration-testing, jakartaee, java, microprofile, system-testing, testing-framework
- Language: Java
- Homepage: https://microshed.org/microshed-testing/
- Size: 1.95 MB
- Stars: 65
- Watchers: 5
- Forks: 24
- Open Issues: 21
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
- awesome-java - MicroShed
README
[](http://microshed.org/microshed-testing)
[](https://mvnrepository.com/artifact/org.microshed/microshed-testing-testcontainers)
[](https://www.javadoc.io/doc/org.microshed/microshed-testing-testcontainers)
[](http://microshed.org/microshed-testing)
[](https://github.com/MicroShed/microshed-testing/actions?query=workflow%3A%22MicroShed+CI%22)
[](https://opensource.org/licenses/Apache-2.0)# Why use MicroShed Testing?
MicroShed Testing offers a fast and simple way of writing and running true-to-production integration
tests for Java microservice applications. MicroShed Testing exercises your containerized application
from outside the container so you are testing the exact same image that runs in production.MicroShed Testing aims to:
1. be easy to get started with
1. work with any Java EE, Jakarta EE or MicroProfile runtime
1. provide true-to-production tests# How to try out a sample locally:
### Run with Maven:
```bash
./gradlew publishToMavenLocal
cd sample-apps/maven-app
mvn clean install
```### Run with Gradle:
```
./gradlew :microshed-testing-jaxrs-json:test
```NOTE: The first run will take longer due to downloading required container layers. Subsequent runs will be faster.
NOTE: If a container is consistantly timing out on your system you can set a longer timeout (in seconds) with the system property
`microshed.testing.startup.timeout` default value is 60 seconds.NOTE: If a mockserver has started, but HTTP calls are consistantly timing out on your system you can set a longer timeout (in milliseconds)
with the system property `mockserver.maxSocketTimeout` default value is 120000 milliseconds.# Supported application-servers:
- OpenLiberty
- Wildfly
- Payara Micro / Full
- Quarkus# Supported runtimes:
`microshed-testing-core` supports the Javax namespace up to and including version 0.9.2. Starting from version 0.9.3, the Jakarta namespace is supported.# Quick Start
To get started writing a test with MicroShed Testing, add `system-test` and `junit-jupiter` as test-scoped dependencies:
```xml
org.microshed
microshed-testing-testcontainers
0.9.2
testorg.junit.jupiter
junit-jupiter
5.10.1
test```
Once you have the above dependencies added, create a new test class with the following items:
1. Annotate the class with `@MicroShedTest`
1. Create a `public static ApplicationContainer` field
1. Inject one or more `public static` JAX-RS resource classes```java
import org.microshed.testing.jaxrs.RESTClient;
import org.microshed.testing.jupiter.MicroShedTest;
import org.microshed.testing.testcontainers.ApplicationContainer;
import org.testcontainers.junit.jupiter.Container;@MicroShedTest
public class MyTest {@Container
public static ApplicationContainer app = new ApplicationContainer()
.withAppContextRoot("/myservice");
@RESTClient
public static MyService mySvc;
// write @Test methods as normal
}
```If the repository containing the tests does not have a `Dockerfile` in it, there are a few other options:
* If the application's container image is produced by a different repository, a String docker image label can be
supplied instead:```java
@Container
public static ApplicationContainer app = new ApplicationContainer("myservice:latest")
.withAppContextRoot("/myservice");
```
* If a Dockerfile or container image label is not available, it is possible to use vendor-specific adapters that will
provide the default logic for building an application container. For example, the `microshed-testing-liberty` adapter will
automatically produce a testable container image roughly equivalent to the following Dockerfile:```
FROM openliberty/open-liberty:full-java17-openj9-ubi
COPY src/main/liberty/config /config/
ADD target/$APP_FILE /config/dropins
```For a more complete introduction, see the [Walkthrough page](https://microshed.org/microshed-testing/features/Walkthrough.html)