-
Notifications
You must be signed in to change notification settings - Fork 298
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/641 revised #834
Closed
Closed
Feature/641 revised #834
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
4b8c9b3
Baseline test for plain jupiter and surefire engines
crizzis 1047fc8
Implemented support for JUnit 5's Disabled and DisabledIf
crizzis 9f5b1ed
Fixed test resolution
crizzis fd88021
Implemented filtering for JUnit 5 tests
crizzis 595e1b9
JUnit Vintage adjustment
crizzis b2596a8
Baseline test for plain jupiter and surefire engines
crizzis 823a5a5
Implemented support for JUnit 5's Disabled and DisabledIf
crizzis 309710d
Fixed test resolution
crizzis 5b3d57d
Implemented filtering for JUnit 5 tests
crizzis f718d40
JUnit Vintage adjustment
crizzis 21363cb
Implemented filtering for Gradle (solves #641)
crizzis dcee94b
Build fix
crizzis ac39dc5
Implemented adapter annotations for JUnit 5 conditions
crizzis e4ff8da
Code style
crizzis 172059a
Implemented filtering for Gradle (solves #641)
crizzis 0a49a56
Build fix
crizzis a8f0c21
Implemented adapter annotations for JUnit 5 conditions
crizzis 2ac75a0
Code style
crizzis 2cf264d
Merge branch 'feature/641-revised' of https://github.com/crizzis/Arch…
crizzis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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
262 changes: 262 additions & 0 deletions
262
...unit-junit/junit5/api/src/main/java/com/tngtech/archunit/junit/conditions/Conditions.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,262 @@ | ||
/* | ||
* Copyright 2014-2022 TNG Technology Consulting GmbH | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.tngtech.archunit.junit.conditions; | ||
|
||
import java.lang.annotation.Documented; | ||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
import com.tngtech.archunit.PublicAPI; | ||
import com.tngtech.archunit.PublicAPI.State; | ||
import com.tngtech.archunit.PublicAPI.Usage; | ||
import com.tngtech.archunit.junit.internal.AdapterFor; | ||
import com.tngtech.archunit.junit.ArchTest; | ||
import org.junit.jupiter.api.condition.JRE; | ||
import org.junit.jupiter.api.condition.OS; | ||
|
||
|
||
/** | ||
* A collection of wrappers for declaring {@code DisabledIfXxx} annotations on {@link ArchTest} annotated fields | ||
*/ | ||
@Target({ }) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Documented | ||
public @interface Conditions { | ||
|
||
@Target(ElementType.FIELD) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@PublicAPI(usage = Usage.ACCESS, state = State.EXPERIMENTAL) | ||
@AdapterFor(org.junit.jupiter.api.condition.DisabledIfEnvironmentVariable.class) | ||
@interface DisabledIfEnvironmentVariable { | ||
String named(); | ||
|
||
/** | ||
* @see org.junit.jupiter.api.condition.DisabledIfEnvironmentVariable#matches() | ||
*/ | ||
String matches(); | ||
|
||
/** | ||
* @see org.junit.jupiter.api.condition.DisabledIfEnvironmentVariable#disabledReason() | ||
*/ | ||
String disabledReason() default ""; | ||
} | ||
|
||
@Target(ElementType.FIELD) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@PublicAPI(usage = Usage.ACCESS, state = State.EXPERIMENTAL) | ||
@AdapterFor(org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable.class) | ||
@interface EnabledIfEnvironmentVariable { | ||
/** | ||
* @see org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable#named() | ||
*/ | ||
String named(); | ||
|
||
/** | ||
* @see org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable#matches() | ||
*/ | ||
String matches(); | ||
|
||
/** | ||
* @see org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable#disabledReason() | ||
*/ | ||
String disabledReason() default ""; | ||
} | ||
|
||
@Target(ElementType.FIELD) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@PublicAPI(usage = Usage.ACCESS, state = State.EXPERIMENTAL) | ||
@AdapterFor(org.junit.jupiter.api.condition.EnabledIfSystemProperty.class) | ||
@interface EnabledIfSystemProperty { | ||
|
||
/** | ||
* @see org.junit.jupiter.api.condition.EnabledIfSystemProperty#named() | ||
*/ | ||
String named(); | ||
|
||
/** | ||
* @see org.junit.jupiter.api.condition.EnabledIfSystemProperty#matches() | ||
*/ | ||
String matches(); | ||
|
||
/** | ||
* @see org.junit.jupiter.api.condition.EnabledIfSystemProperty#disabledReason() | ||
*/ | ||
String disabledReason() default ""; | ||
} | ||
|
||
@Target(ElementType.FIELD) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@PublicAPI(usage = Usage.ACCESS, state = State.EXPERIMENTAL) | ||
@AdapterFor(org.junit.jupiter.api.condition.DisabledIfSystemProperty.class) | ||
@interface DisabledIfSystemProperty { | ||
|
||
/** | ||
* @see org.junit.jupiter.api.condition.DisabledIfSystemProperty#named() | ||
*/ | ||
String named(); | ||
|
||
/** | ||
* @see org.junit.jupiter.api.condition.DisabledIfSystemProperty#matches() | ||
*/ | ||
String matches(); | ||
|
||
/** | ||
* @see org.junit.jupiter.api.condition.DisabledIfSystemProperty#disabledReason() | ||
*/ | ||
String disabledReason() default ""; | ||
} | ||
|
||
@Target(ElementType.FIELD) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@PublicAPI(usage = Usage.ACCESS, state = State.EXPERIMENTAL) | ||
@AdapterFor(org.junit.jupiter.api.condition.EnabledOnJre.class) | ||
@interface EnabledOnJre { | ||
|
||
/** | ||
* @see org.junit.jupiter.api.condition.EnabledOnJre#value() | ||
*/ | ||
JRE[] value(); | ||
|
||
/** | ||
* @see org.junit.jupiter.api.condition.EnabledOnJre#disabledReason() | ||
*/ | ||
String disabledReason() default ""; | ||
} | ||
|
||
@Target(ElementType.FIELD) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@PublicAPI(usage = Usage.ACCESS, state = State.EXPERIMENTAL) | ||
@AdapterFor(org.junit.jupiter.api.condition.DisabledOnJre.class) | ||
@interface DisabledOnJre { | ||
/** | ||
* @see org.junit.jupiter.api.condition.DisabledOnJre#value() | ||
*/ | ||
JRE[] value(); | ||
|
||
/** | ||
* @see org.junit.jupiter.api.condition.DisabledOnJre#disabledReason() | ||
*/ | ||
String disabledReason() default ""; | ||
} | ||
|
||
@Target(ElementType.FIELD) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@PublicAPI(usage = Usage.ACCESS, state = State.EXPERIMENTAL) | ||
@AdapterFor(org.junit.jupiter.api.condition.EnabledForJreRange.class) | ||
@interface EnabledForJreRange { | ||
/** | ||
* @see org.junit.jupiter.api.condition.EnabledForJreRange#min() | ||
*/ | ||
JRE min() default JRE.JAVA_8; | ||
|
||
/** | ||
* @see org.junit.jupiter.api.condition.EnabledForJreRange#max() | ||
*/ | ||
JRE max() default JRE.OTHER; | ||
|
||
/** | ||
* @see org.junit.jupiter.api.condition.EnabledForJreRange#disabledReason() | ||
*/ | ||
String disabledReason() default ""; | ||
} | ||
|
||
@Target(ElementType.FIELD) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@PublicAPI(usage = Usage.ACCESS, state = State.EXPERIMENTAL) | ||
@AdapterFor(org.junit.jupiter.api.condition.DisabledForJreRange.class) | ||
@interface DisabledForJreRange { | ||
/** | ||
* @see org.junit.jupiter.api.condition.DisabledForJreRange#min() | ||
*/ | ||
JRE min() default JRE.JAVA_8; | ||
|
||
/** | ||
* @see org.junit.jupiter.api.condition.DisabledForJreRange#max() | ||
*/ | ||
JRE max() default JRE.OTHER; | ||
|
||
/** | ||
* @see org.junit.jupiter.api.condition.DisabledForJreRange#disabledReason() | ||
*/ | ||
String disabledReason() default ""; | ||
} | ||
|
||
@Target(ElementType.FIELD) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@PublicAPI(usage = Usage.ACCESS, state = State.EXPERIMENTAL) | ||
@AdapterFor(org.junit.jupiter.api.condition.EnabledOnOs.class) | ||
@interface EnabledOnOs { | ||
/** | ||
* @see org.junit.jupiter.api.condition.EnabledOnOs#value() | ||
*/ | ||
OS[] value(); | ||
|
||
/** | ||
* @see org.junit.jupiter.api.condition.EnabledOnOs#disabledReason() | ||
*/ | ||
String disabledReason() default ""; | ||
} | ||
|
||
@Target(ElementType.FIELD) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@PublicAPI(usage = Usage.ACCESS, state = State.EXPERIMENTAL) | ||
@AdapterFor(org.junit.jupiter.api.condition.DisabledOnOs.class) | ||
@interface DisabledOnOs { | ||
/** | ||
* @see org.junit.jupiter.api.condition.DisabledOnOs#value() | ||
*/ | ||
OS[] value(); | ||
|
||
/** | ||
* @see org.junit.jupiter.api.condition.DisabledOnOs#disabledReason() | ||
*/ | ||
String disabledReason() default ""; | ||
} | ||
|
||
@Target(ElementType.FIELD) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@PublicAPI(usage = Usage.ACCESS, state = State.EXPERIMENTAL) | ||
@AdapterFor(org.junit.jupiter.api.condition.EnabledIf.class) | ||
@interface EnabledIf { | ||
/** | ||
* @see org.junit.jupiter.api.condition.EnabledIf#value() | ||
*/ | ||
String value(); | ||
|
||
/** | ||
* @see org.junit.jupiter.api.condition.EnabledIf#disabledReason() | ||
*/ | ||
String disabledReason() default ""; | ||
} | ||
|
||
@Target(ElementType.FIELD) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@PublicAPI(usage = Usage.ACCESS, state = State.EXPERIMENTAL) | ||
@AdapterFor(org.junit.jupiter.api.condition.DisabledIf.class) | ||
@interface DisabledIf { | ||
/** | ||
* @see org.junit.jupiter.api.condition.DisabledIf#value() | ||
*/ | ||
String value(); | ||
|
||
/** | ||
* @see org.junit.jupiter.api.condition.DisabledIf#disabledReason() | ||
*/ | ||
String disabledReason() default ""; | ||
} | ||
} |
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that for method-flavored ArchUnit tests, the default
org.junit.jupiter.api.condition
annotations now work just fine.The annotations in this file are only needed for field-flavored tests, because the original JUnit annotations fail to declare
FIELD
s as annotation targets.