This extension for JUnit 5 acts like there are no tests, because if you don't have any, they can't fail, right?
Sample JUnit Results (no matter how many tests you've developed!):
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
As Maven dependency
<repositories>
<repository>
<id>junit-trump-extension</id>
<url>https://mymavenrepo.com/repo/v3i97KuHAZF1V0yF9mn0/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>id.niklas</groupId>
<artifactId>junit-trump-extension</artifactId>
<version>1.0.0</version>
<scope>test</scope>
</dependency>
</dependencies>
As Gradle dependency
allprojects {
repositories {
maven { url 'https://mymavenrepo.com/repo/v3i97KuHAZF1V0yF9mn0/' }
}
}
dependencies {
testImplementation 'id.niklas:junit-trump-extension:1.0.0'
}
As SBT dependency
resolvers += "junit-trump-extension" at "https://mymavenrepo.com/repo/v3i97KuHAZF1V0yF9mn0"
libraryDependencies += "id.niklas" % "junit-trump-extension" % "1.0.0" % "test"
There are three ways to register this JUnit extension:
- Enable automatic detection extension by setting the system property
junit.jupiter.extensions.autodetection.enabled=true
(either in yourpom.xml
or as a VM option).
Then add a/META-INF/services/org.junit.jupiter.api.extension.Extension
file and specifyid.niklas.junit_trump_extension.JUnitTrumpExtension
as its sole content. - Register the extension declaratively by annotating test classes with
@ExtendWith(JUnitTrumpExtension.class)
. - Register the extension programmatically by adding a static field to your test classes:
@RegisterExtension
static JUnitTrumpExtension trumpExtension = new JUnitTrumpExtension();
Check out the src/test
directory to see an example.
This project was inspired by icanhazstring/phpunit-trump-extension who originally had the idea to provide a PHPUnit Trump Extension.
This project is licensed under the MIT License. See the LICENSE file for details.