Browse Source

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.
pull/23480/head
Phillip Webb 7 years ago
parent
commit
f8a93ee4a7
  1. 3
      src/checkstyle/checkstyle-suppressions.xml
  2. 1
      src/checkstyle/checkstyle.xml

3
src/checkstyle/checkstyle-suppressions.xml

@ -4,6 +4,7 @@ @@ -4,6 +4,7 @@
<!-- global -->
<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" />
<suppress files="[\\/]src[\\/]test[\\/]java[\\/]" checks="SpringJUnit5" message="should not be public" />
<!-- spring-beans -->
<suppress files="TypeMismatchException" checks="MutableException"/>
@ -70,6 +71,8 @@ @@ -70,6 +71,8 @@
<suppress files="HeaderAssertions" checks="IllegalImport" id="bannedHamcrestImports" />
<suppress files="StatusAssertions" checks="IllegalImport" id="bannedHamcrestImports" />
<suppress files="JsonPathResultMatchers" checks="IllegalImport" id="bannedHamcrestImports" />
<suppress files="src[\\/]test[\\/]java[\\/]org[\\/]springframework[\\/]test[\\/]context[\\/]junit4" checks="SpringJUnit5"/>
<suppress files="ContextHierarchyDirtiesContextTests|ClassLevelDirtiesContextTests|ContextConfigurationWithPropertiesExtendingPropertiesAndInheritedLoaderTests|ContextConfigurationWithPropertiesExtendingPropertiesTests|DirtiesContextInterfaceTests|.*WacTests|JUnit4SpringContextWebTests" checks="SpringJUnit5"/>
<!-- spring-web -->
<suppress files="SpringHandlerInstantiator" checks="JavadocStyle" />

1
src/checkstyle/checkstyle.xml

@ -211,5 +211,6 @@ @@ -211,5 +211,6 @@
</module>
<module name="io.spring.javaformat.checkstyle.check.SpringCatchCheck" />
<module name="io.spring.javaformat.checkstyle.check.SpringJavadocCheck" />
<module name="io.spring.javaformat.checkstyle.check.SpringJUnit5Check" />
</module>
</module>

Loading…
Cancel
Save