Skip to content

Commit e0c184d

Browse files
committed
Apply CheckTestNameTest verifying issues rules to only tests
1 parent 2ce511e commit e0c184d

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

delphi-checks/src/test/java/au/com/integradev/delphi/checks/CheckTestNameTest.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,15 @@
2828
import com.tngtech.archunit.core.domain.JavaMember;
2929
import com.tngtech.archunit.core.domain.JavaMethod;
3030
import com.tngtech.archunit.core.domain.JavaModifier;
31+
import com.tngtech.archunit.core.domain.properties.CanBeAnnotated.Predicates;
3132
import com.tngtech.archunit.core.domain.properties.HasName;
3233
import com.tngtech.archunit.core.importer.ClassFileImporter;
3334
import com.tngtech.archunit.lang.ArchCondition;
3435
import com.tngtech.archunit.lang.ConditionEvents;
3536
import com.tngtech.archunit.lang.SimpleConditionEvent;
3637
import java.util.List;
3738
import org.junit.jupiter.api.Test;
39+
import org.junit.jupiter.params.ParameterizedTest;
3840
import org.sonar.plugins.communitydelphi.api.check.DelphiCheck;
3941

4042
class CheckTestNameTest {
@@ -123,6 +125,10 @@ void testCheckTestsVerifyingIssuesAreNamedCorrectly() {
123125
methods()
124126
.that(VERIFY_ISSUES)
125127
.and(not(TESTING_IMPLEMENTATION_DETAILS))
128+
.and(
129+
DescribedPredicate.or(
130+
Predicates.annotatedWith(Test.class),
131+
Predicates.annotatedWith(ParameterizedTest.class)))
126132
.should()
127133
.haveNameMatching(".*ShouldAdd(Issues?|QuickFix(es)?)$")
128134
.allowEmptyShould(true)
@@ -135,6 +141,10 @@ void testCheckTestsVerifyingNoIssuesAreNamedCorrectly() {
135141
.that(VERIFY_NO_ISSUES)
136142
.and(not(TESTING_IMPLEMENTATION_DETAILS))
137143
.and(not(CALL_ASSERT_THROW_BY))
144+
.and(
145+
DescribedPredicate.or(
146+
Predicates.annotatedWith(Test.class),
147+
Predicates.annotatedWith(ParameterizedTest.class)))
138148
.should()
139149
.haveNameMatching(".*ShouldNotAddIssues?$")
140150
.allowEmptyShould(true)
@@ -166,8 +176,10 @@ void testCheckTestsShouldNotThrowAreNamedCorrectly() {
166176
@Test
167177
void testCheckTestsShouldBeNamedCorrectly() {
168178
methods()
169-
.that()
170-
.areAnnotatedWith(Test.class)
179+
.that(
180+
DescribedPredicate.or(
181+
Predicates.annotatedWith(Test.class),
182+
Predicates.annotatedWith(ParameterizedTest.class)))
171183
.and(not(DECLARED_IN_METATESTS))
172184
.should()
173185
.haveNameMatching(".*Should((Not)?(Throw|Add(Issues?|QuickFix(es)?)))")

0 commit comments

Comments
 (0)