-
Notifications
You must be signed in to change notification settings - Fork 298
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add JUnit5-support for
@ArchTest
members in abstract base classes
So far, having `@ArchTest` fields or methods in an abstract base class would cause the JUnit 5 engine to crash. This also made the pattern to "share" tests via extending a common base class impossible, which some users would like to have. The change corresponds to the commits * 8188cdc * 625c3d6 * 59f8c4d which added the same feature for JUnit4 (Issue: #104). Signed-off-by: Manfred Hanke <[email protected]>
- Loading branch information
1 parent
69d4398
commit b52ce64
Showing
8 changed files
with
171 additions
and
27 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
13 changes: 13 additions & 0 deletions
13
...ech/archunit/junit/internal/testexamples/abstractbase/AbstractBaseClassWithFieldRule.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,13 @@ | ||
package com.tngtech.archunit.junit.internal.testexamples.abstractbase; | ||
|
||
import com.tngtech.archunit.junit.ArchTest; | ||
import com.tngtech.archunit.junit.internal.testexamples.RuleThatFails; | ||
import com.tngtech.archunit.junit.internal.testexamples.UnwantedClass; | ||
import com.tngtech.archunit.lang.ArchRule; | ||
|
||
public abstract class AbstractBaseClassWithFieldRule { | ||
public static final String INSTANCE_FIELD_NAME = "abstractBaseClassInstanceField"; | ||
|
||
@ArchTest | ||
ArchRule abstractBaseClassInstanceField = RuleThatFails.on(UnwantedClass.CLASS_VIOLATING_RULES); | ||
} |
13 changes: 13 additions & 0 deletions
13
...internal/testexamples/abstractbase/AbstractBaseClassWithLibraryWithAbstractBaseClass.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,13 @@ | ||
package com.tngtech.archunit.junit.internal.testexamples.abstractbase; | ||
|
||
import com.tngtech.archunit.junit.ArchTest; | ||
import com.tngtech.archunit.junit.ArchTests; | ||
|
||
public abstract class AbstractBaseClassWithLibraryWithAbstractBaseClass { | ||
public static final String FIELD_RULE_LIBRARY_NAME = "fieldRules"; | ||
public static final String METHOD_RULE_LIBRARY_NAME = "methodRules"; | ||
@ArchTest | ||
ArchTests fieldRules = ArchTests.in(ArchTestWithAbstractBaseClassWithFieldRule.class); | ||
@ArchTest | ||
ArchTests methodRules = ArchTests.in(ArchTestWithAbstractBaseClassWithMethodRule.class); | ||
} |
15 changes: 15 additions & 0 deletions
15
...ch/archunit/junit/internal/testexamples/abstractbase/AbstractBaseClassWithMethodRule.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,15 @@ | ||
package com.tngtech.archunit.junit.internal.testexamples.abstractbase; | ||
|
||
import com.tngtech.archunit.core.domain.JavaClasses; | ||
import com.tngtech.archunit.junit.ArchTest; | ||
import com.tngtech.archunit.junit.internal.testexamples.RuleThatFails; | ||
import com.tngtech.archunit.junit.internal.testexamples.UnwantedClass; | ||
|
||
public abstract class AbstractBaseClassWithMethodRule { | ||
public static final String INSTANCE_METHOD_NAME = "abstractBaseClassInstanceMethod"; | ||
|
||
@ArchTest | ||
void abstractBaseClassInstanceMethod(JavaClasses classes) { | ||
RuleThatFails.on(UnwantedClass.CLASS_VIOLATING_RULES).check(classes); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
.../junit/internal/testexamples/abstractbase/ArchTestWithAbstractBaseClassWithFieldRule.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,7 @@ | ||
package com.tngtech.archunit.junit.internal.testexamples.abstractbase; | ||
|
||
import com.tngtech.archunit.junit.AnalyzeClasses; | ||
|
||
@AnalyzeClasses(packages = "some.dummy.package") | ||
public class ArchTestWithAbstractBaseClassWithFieldRule extends AbstractBaseClassWithFieldRule { | ||
} |
7 changes: 7 additions & 0 deletions
7
...junit/internal/testexamples/abstractbase/ArchTestWithAbstractBaseClassWithMethodRule.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,7 @@ | ||
package com.tngtech.archunit.junit.internal.testexamples.abstractbase; | ||
|
||
import com.tngtech.archunit.junit.AnalyzeClasses; | ||
|
||
@AnalyzeClasses(packages = "some.dummy.package") | ||
public class ArchTestWithAbstractBaseClassWithMethodRule extends AbstractBaseClassWithMethodRule { | ||
} |
7 changes: 7 additions & 0 deletions
7
...it/junit/internal/testexamples/abstractbase/ArchTestWithLibraryWithAbstractBaseClass.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,7 @@ | ||
package com.tngtech.archunit.junit.internal.testexamples.abstractbase; | ||
|
||
import com.tngtech.archunit.junit.AnalyzeClasses; | ||
|
||
@AnalyzeClasses(packages = "some.dummy.package") | ||
public class ArchTestWithLibraryWithAbstractBaseClass extends AbstractBaseClassWithLibraryWithAbstractBaseClass { | ||
} |