AMLSim
/
jars
/junit5-r5.10.2
/documentation
/src
/test
/java
/example
/ConditionalTestExecutionDemo.java
/* | |
* Copyright 2015-2023 the original author or authors. | |
* | |
* All rights reserved. This program and the accompanying materials are | |
* made available under the terms of the Eclipse Public License v2.0 which | |
* accompanies this distribution and is available at | |
* | |
* https://www.eclipse.org/legal/epl-v20.html | |
*/ | |
package example; | |
import static org.junit.jupiter.api.condition.JRE.JAVA_10; | |
import static org.junit.jupiter.api.condition.JRE.JAVA_11; | |
import static org.junit.jupiter.api.condition.JRE.JAVA_8; | |
import static org.junit.jupiter.api.condition.JRE.JAVA_9; | |
import static org.junit.jupiter.api.condition.OS.LINUX; | |
import static org.junit.jupiter.api.condition.OS.MAC; | |
import static org.junit.jupiter.api.condition.OS.WINDOWS; | |
import java.lang.annotation.ElementType; | |
import java.lang.annotation.Retention; | |
import java.lang.annotation.RetentionPolicy; | |
import java.lang.annotation.Target; | |
import org.junit.jupiter.api.Test; | |
import org.junit.jupiter.api.condition.DisabledForJreRange; | |
import org.junit.jupiter.api.condition.DisabledIf; | |
import org.junit.jupiter.api.condition.DisabledIfEnvironmentVariable; | |
import org.junit.jupiter.api.condition.DisabledIfSystemProperty; | |
import org.junit.jupiter.api.condition.DisabledInNativeImage; | |
import org.junit.jupiter.api.condition.DisabledOnJre; | |
import org.junit.jupiter.api.condition.DisabledOnOs; | |
import org.junit.jupiter.api.condition.EnabledForJreRange; | |
import org.junit.jupiter.api.condition.EnabledIf; | |
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable; | |
import org.junit.jupiter.api.condition.EnabledIfSystemProperty; | |
import org.junit.jupiter.api.condition.EnabledInNativeImage; | |
import org.junit.jupiter.api.condition.EnabledOnJre; | |
import org.junit.jupiter.api.condition.EnabledOnOs; | |
class ConditionalTestExecutionDemo { | |
// tag::user_guide_os[] | |
void onlyOnMacOs() { | |
// ... | |
} | |
void testOnMac() { | |
// ... | |
} | |
void onLinuxOrMac() { | |
// ... | |
} | |
void notOnWindows() { | |
// ... | |
} | |
TestOnMac { | |
} | |
// end::user_guide_os[] | |
// tag::user_guide_architecture[] | |
void onAarch64() { | |
// ... | |
} | |
void notOnX86_64() { | |
// ... | |
} | |
void onNewMacs() { | |
// ... | |
} | |
void notOnNewMacs() { | |
// ... | |
} | |
// end::user_guide_architecture[] | |
// tag::user_guide_jre[] | |
void onlyOnJava8() { | |
// ... | |
} | |
void onJava9Or10() { | |
// ... | |
} | |
void fromJava9to11() { | |
// ... | |
} | |
void fromJava9toCurrentJavaFeatureNumber() { | |
// ... | |
} | |
void fromJava8To11() { | |
// ... | |
} | |
void notOnJava9() { | |
// ... | |
} | |
void notFromJava9to11() { | |
// ... | |
} | |
void notFromJava9toCurrentJavaFeatureNumber() { | |
// ... | |
} | |
void notFromJava8to11() { | |
// ... | |
} | |
// end::user_guide_jre[] | |
// tag::user_guide_native[] | |
void onlyWithinNativeImage() { | |
// ... | |
} | |
void neverWithinNativeImage() { | |
// ... | |
} | |
// end::user_guide_native[] | |
// tag::user_guide_system_property[] | |
void onlyOn64BitArchitectures() { | |
// ... | |
} | |
void notOnCiServer() { | |
// ... | |
} | |
// end::user_guide_system_property[] | |
// tag::user_guide_environment_variable[] | |
void onlyOnStagingServer() { | |
// ... | |
} | |
void notOnDeveloperWorkstation() { | |
// ... | |
} | |
// end::user_guide_environment_variable[] | |
// tag::user_guide_custom[] | |
void enabled() { | |
// ... | |
} | |
void disabled() { | |
// ... | |
} | |
boolean customCondition() { | |
return true; | |
} | |
// end::user_guide_custom[] | |
} | |