-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Provide a new JUnit 5 Rule checking test methods are package private
Closes gh-27
- Loading branch information
Showing
7 changed files
with
115 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.enofex.taikai; | ||
|
||
import com.tngtech.archunit.base.DescribedPredicate; | ||
import com.tngtech.archunit.core.domain.properties.CanBeAnnotated; | ||
|
||
public final class AnnotationPredicates { | ||
|
||
private AnnotationPredicates() { | ||
} | ||
|
||
public static DescribedPredicate<CanBeAnnotated> annotatedWith(String annotation, | ||
boolean isMetaAnnotated) { | ||
return new DescribedPredicate<>("annotated with %s".formatted(annotation)) { | ||
@Override | ||
public boolean test(CanBeAnnotated canBeAnnotated) { | ||
return isMetaAnnotated ? canBeAnnotated.isMetaAnnotatedWith(annotation) : | ||
canBeAnnotated.isAnnotatedWith(annotation); | ||
} | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
src/main/java/com/enofex/taikai/test/JUnit5Predicates.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.enofex.taikai.test; | ||
|
||
import static com.enofex.taikai.AnnotationPredicates.annotatedWith; | ||
|
||
import com.tngtech.archunit.base.DescribedPredicate; | ||
import com.tngtech.archunit.core.domain.properties.CanBeAnnotated; | ||
|
||
final class JUnit5Predicates { | ||
|
||
static final String ANNOTATION_TEST = "org.junit.jupiter.api.Test"; | ||
static final String ANNOTATION_PARAMETRIZED_TEST = "org.junit.jupiter.params.ParameterizedTest"; | ||
|
||
private JUnit5Predicates() { | ||
} | ||
|
||
static DescribedPredicate<CanBeAnnotated> annotatedWithTestOrParameterizedTest( | ||
boolean isMetaAnnotated) { | ||
|
||
return annotatedWith(ANNOTATION_TEST, isMetaAnnotated) | ||
.or(annotatedWith(ANNOTATION_PARAMETRIZED_TEST, isMetaAnnotated)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.