Bael 3850: EnabledForJRERange and DisabledForJRERange JUnit Annotations (#8724)
* Upgraded to Jupiter 5.6.0 Also removed some deprecated stuff! * Added a new test * Resotre Delete Tests
This commit is contained in:
parent
9da978ec65
commit
80b7fed6e1
|
@ -49,8 +49,8 @@
|
|||
</dependencies>
|
||||
|
||||
<properties>
|
||||
<junit.jupiter.version>5.4.2</junit.jupiter.version>
|
||||
<junit.platform.version>1.4.2</junit.platform.version>
|
||||
<junit.jupiter.version>5.6.0</junit.jupiter.version>
|
||||
<junit.platform.version>1.6.0</junit.platform.version>
|
||||
<log4j2.version>2.8.2</log4j2.version>
|
||||
</properties>
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ import java.lang.annotation.RetentionPolicy;
|
|||
import java.lang.annotation.Target;
|
||||
|
||||
public class ConditionalAnnotationsUnitTest {
|
||||
|
||||
@Test
|
||||
@EnabledOnOs({OS.WINDOWS, OS.MAC})
|
||||
public void shouldRunBothWindowsAndMac() {
|
||||
|
@ -28,6 +29,18 @@ public class ConditionalAnnotationsUnitTest {
|
|||
System.out.println("runs with java 10 and 11");
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnabledForJreRange(min = JRE.JAVA_8, max = JRE.JAVA_13)
|
||||
public void shouldOnlyRunOnJava8UntilJava13() {
|
||||
System.out.println("runs with Java 8, 9, 10, 11, 12 and 13!");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisabledForJreRange(min = JRE.JAVA_14, max = JRE.JAVA_15)
|
||||
public void shouldNotBeRunOnJava14AndJava15() {
|
||||
System.out.println("Shouldn't be run on Java 14 and 15.");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisabledOnJre(JRE.OTHER)
|
||||
public void thisTestOnlyRunsWithUpToDateJREs() {
|
||||
|
@ -58,36 +71,38 @@ public class ConditionalAnnotationsUnitTest {
|
|||
System.out.println("will not run if environment variable LC_TIME is UTF-8");
|
||||
}
|
||||
|
||||
// Commented codes are going to work prior JUnit 5.5
|
||||
|
||||
@Test
|
||||
@EnabledIf("'FR' == systemProperty.get('user.country')")
|
||||
// @EnabledIf("'FR' == systemProperty.get('user.country')")
|
||||
public void onlyFrenchPeopleWillRunThisMethod() {
|
||||
System.out.println("will run only if user.country is FR");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisabledIf("java.lang.System.getProperty('os.name').toLowerCase().contains('mac')")
|
||||
// @DisabledIf("java.lang.System.getProperty('os.name').toLowerCase().contains('mac')")
|
||||
public void shouldNotRunOnMacOS() {
|
||||
System.out.println("will not run if our os.name is mac");
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnabledIf(value = {
|
||||
"load('nashorn:mozilla_compat.js')",
|
||||
"importPackage(java.time)",
|
||||
"",
|
||||
"var thisMonth = LocalDate.now().getMonth().name()",
|
||||
"var february = Month.FEBRUARY.name()",
|
||||
"thisMonth.equals(february)"
|
||||
/*@EnabledIf(value = {
|
||||
"load('nashorn:mozilla_compat.js')",
|
||||
"importPackage(java.time)",
|
||||
"",
|
||||
"var thisMonth = LocalDate.now().getMonth().name()",
|
||||
"var february = Month.FEBRUARY.name()",
|
||||
"thisMonth.equals(february)"
|
||||
},
|
||||
engine = "nashorn",
|
||||
reason = "Self-fulfilling: {result}")
|
||||
engine = "nashorn",
|
||||
reason = "Self-fulfilling: {result}")*/
|
||||
public void onlyRunsInFebruary() {
|
||||
System.out.println("this test only runs in February");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisabledIf("systemEnvironment.get('XPC_SERVICE_NAME') != null " +
|
||||
"&& systemEnvironment.get('XPC_SERVICE_NAME').contains('intellij')")
|
||||
/*@DisabledIf("systemEnvironment.get('XPC_SERVICE_NAME') != null " +
|
||||
"&& systemEnvironment.get('XPC_SERVICE_NAME').contains('intellij')")*/
|
||||
public void notValidForIntelliJ() {
|
||||
System.out.println("this test will run if our ide is INTELLIJ");
|
||||
}
|
||||
|
@ -107,7 +122,7 @@ public class ConditionalAnnotationsUnitTest {
|
|||
|
||||
@Target(ElementType.METHOD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@DisabledIf("Math.random() >= 0.5")
|
||||
// @DisabledIf("Math.random() >= 0.5")
|
||||
@interface CoinToss {
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue