blob: cf92421a3de1f5d11085593240ef50ee3f39b8a3 [file] [log] [blame]
= Apache Winegrower JUnit5
Apache Winegrower JUnit5 allows to rely on the modern JUnit 5 framework
to test your application.
== Dependency
[source,xml]
----
<dependency>
<groupId>org.apache.winegrower</groupId>
<artifactId>winegrower-testing-junit5</artifactId>
<version>${winegrower.version}</version>
</dependency>
----
== @Winegrower
`@Winegrower` allows to start a `Ripener` per class. Each test class
will use its own configuration based on the setup done thanks to
`@Winegrower`.
Example:
[source,java]
----
@Winegrower
class WinegrowerExtensionTest {
@Test
void doYourTest() {
// ...
}
}
----
== @MonoWinegrower
`@MonoWinegrower` is close to the previous flavor but it starts the `Ripener`
a single time for the whole JVM lifecycle. It takes its configuration from a
SPI on `Ripener.Configuration` class (registered thanks to `META-INF/services/org.apache.winegrower.Ripener$Configuration`).
If you don't register a custom configuration, default one is used.
IMPORTANT: this flavor boots your performances but all your test classes will
share the same state so ensure to not leak anything which can impact another test.
Example:
[source,java]
----
@MonoWinegrower
class WinegrowerExtensionTest {
@Test
void doYourTest() {
// ...
}
}
----
== Inject your Services
You can get services injected using `@InjectedService` in a class field.
It also supports the `Ripener` and `OSGiServices`. These last two can be injected
as test method parameters as well:
[source,java]
----
@Winegrower
class WinegrowerExtensionTest {
@InjectedService
private Ripener ripener;
@InjectedService
private OSGiServices services;
@Test
void myTest(final Ripener ripener) {
// ....
}
}
----