Skip to content

Commit f8a93ee

Browse files
committed
Add SpringJUnit5 checkstyle rule
Add `SpringJUnit5` checkstyle rule to ensure that JUnit 4 annotations aren't accidentally used in new tests. The "must not be public" rule has been suppressed since there are quite a few tests that extend base tests from other packages.
1 parent 0db2f8f commit f8a93ee

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

src/checkstyle/checkstyle-suppressions.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
<!-- global -->
66
<suppress files="[\\/]src[\\/]test[\\/]java[\\/]" checks="AnnotationLocation|AnnotationUseStyle|AtclauseOrder|AvoidNestedBlocks|FinalClass|HideUtilityClassConstructor|InnerTypeLast|JavadocStyle|JavadocType|JavadocVariable|LeftCurly|MultipleVariableDeclarations|NeedBraces|OneTopLevelClass|OuterTypeFilename|RequireThis|SpringCatch|SpringJavadoc|SpringNoThis" />
7+
<suppress files="[\\/]src[\\/]test[\\/]java[\\/]" checks="SpringJUnit5" message="should not be public" />
78

89
<!-- spring-beans -->
910
<suppress files="TypeMismatchException" checks="MutableException"/>
@@ -70,6 +71,8 @@
7071
<suppress files="HeaderAssertions" checks="IllegalImport" id="bannedHamcrestImports" />
7172
<suppress files="StatusAssertions" checks="IllegalImport" id="bannedHamcrestImports" />
7273
<suppress files="JsonPathResultMatchers" checks="IllegalImport" id="bannedHamcrestImports" />
74+
<suppress files="src[\\/]test[\\/]java[\\/]org[\\/]springframework[\\/]test[\\/]context[\\/]junit4" checks="SpringJUnit5"/>
75+
<suppress files="ContextHierarchyDirtiesContextTests|ClassLevelDirtiesContextTests|ContextConfigurationWithPropertiesExtendingPropertiesAndInheritedLoaderTests|ContextConfigurationWithPropertiesExtendingPropertiesTests|DirtiesContextInterfaceTests|.*WacTests|JUnit4SpringContextWebTests" checks="SpringJUnit5"/>
7376

7477
<!-- spring-web -->
7578
<suppress files="SpringHandlerInstantiator" checks="JavadocStyle" />

src/checkstyle/checkstyle.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,5 +211,6 @@
211211
</module>
212212
<module name="io.spring.javaformat.checkstyle.check.SpringCatchCheck" />
213213
<module name="io.spring.javaformat.checkstyle.check.SpringJavadocCheck" />
214+
<module name="io.spring.javaformat.checkstyle.check.SpringJUnit5Check" />
214215
</module>
215216
</module>

0 commit comments

Comments
 (0)