Skip to content

Commit 8c74103

Browse files
authored
Merge pull request #371 from uhafner/package-private-tests
Package private tests
2 parents 7e1a01d + 2712066 commit 8c74103

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

etc/pmd-configuration.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<exclude name="UnusedImports"/>
1414
<exclude name="GuardLogStatement"/>
1515
<exclude name="AccessorMethodGeneration"/>
16+
<exclude name="JUnit5TestShouldBePackagePrivate"/>
1617
<exclude name="UnusedPrivateMethod"/>
1718
</rule>
1819
<rule ref="category/java/codestyle.xml">

src/test/java/edu/hm/hafner/util/ArchitectureRules.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,13 @@ private ArchitectureRules() {
4040
.and().doNotHaveModifier(JavaModifier.ABSTRACT)
4141
.should().bePublic();
4242

43-
/** Junit 5 test methods should not be public. */
44-
public static final ArchRule NO_PUBLIC_TEST_METHODS =
43+
/** Junit 5 test methods should be package private. */
44+
public static final ArchRule ONLY_PACKAGE_PRIVATE_TEST_METHODS =
4545
methods().that().areAnnotatedWith(Test.class)
4646
.or().areAnnotatedWith(ParameterizedTest.class)
4747
.and().areDeclaredInClassesThat()
4848
.haveSimpleNameEndingWith("Test")
49-
.should().notBePublic();
49+
.should().bePackagePrivate();
5050

5151
/** ArchUnit tests should not be public. */
5252
public static final ArchRule NO_PUBLIC_ARCHITECTURE_TESTS =

src/test/java/edu/hm/hafner/util/ArchitectureTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class ArchitectureTest {
1616
static final ArchRule NO_PUBLIC_TEST_CLASSES = ArchitectureRules.NO_PUBLIC_TEST_CLASSES;
1717

1818
@ArchTest
19-
static final ArchRule NO_PUBLIC_TEST_METHODS = ArchitectureRules.NO_PUBLIC_TEST_METHODS;
19+
static final ArchRule ONLY_PACKAGE_PRIVATE_TEST_METHODS = ArchitectureRules.ONLY_PACKAGE_PRIVATE_TEST_METHODS;
2020

2121
@ArchTest
2222
static final ArchRule NO_PUBLIC_ARCHITECTURE_TESTS = ArchitectureRules.NO_PUBLIC_ARCHITECTURE_TESTS;

0 commit comments

Comments
 (0)