Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ You can set up `mvn spotless:apply` to run automatically (in `validate` phase) f

## Additional Checks

You can set the `ban-junit4-imports.skip` property to `false` if your tests are written with JUnit 5 (Jupiter) and you want to ensure that no JUnit 4 imports are used in your plugin.
You can set the `ban-junit4-imports.skip` property to `false` if your tests are written with JUnit Jupiter and you want to ensure that no JUnit 4 imports are used in your plugin.
This will prevent imports of JUnit 4 classes in your code to ensure newly added or improved tests do not reintroduce JUnit 4 (e.g., out of habit or from IDE import autocompletion).
Note that this will only address _imports_ of JUnit 4 in your code, and not uses from dependencies, or even use of fully qualified class names.

Expand Down
7 changes: 1 addition & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -216,11 +216,6 @@
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
Expand Down Expand Up @@ -680,7 +675,7 @@
<configuration>
<rules>
<RestrictImports>
<reason>Use JUnit 5 (org.junit.jupiter.*)</reason>
<reason>Use JUnit Jupiter (org.junit.jupiter.*)</reason>
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the naming to be more consistent, since we are using JUnit 6.x by now.

<bannedImports>
<bannedImport>junit.**</bannedImport>
<bannedImport>org.junit.**</bannedImport>
Expand Down
2 changes: 1 addition & 1 deletion src/it/ban-junit4-fail/postbuild.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ assert !hpi.exists()

// Because of banned imports
def log = new File(basedir, 'build.log')
assert log.text.contains('Reason: Use JUnit 5 (org.junit.jupiter.*)')
assert log.text.contains('Reason: Use JUnit Jupiter (org.junit.jupiter.*)')
assert log.text.contains('org.junit.Test')
assert log.text.contains('(Line: 3, Matched by: org.junit.**)')
assert log.text.contains('static org.junit.Assert.assertTrue')
Expand Down
Loading