인프런의 "더 자바, 애플리케이션을 테스트하는 다양한 방법”을 보고 정리한 것임
@Test
void assumeTrueTest() {
String test_env = System.getenv("TEST_ENV");
System.out.println(test_env);
assumeTrue("LOCAL".equalsIgnoreCase(test_env));
Study study = new Study(10);
assertThat(study.getLimit()).isGreaterThan(0);
}
@Test
void assumeThatTest() {
String test_env = System.getenv("TEST_ENV");
assumingThat("LOCAL".equalsIgnoreCase(test_env),
() -> {
System.out.println("local");
Study study = new Study(10);
assertThat(study.getLimit()).isGreaterThan(0);
});
assumingThat("DEV".equalsIgnoreCase(test_env),
() -> {
System.out.println("dev");
Study study = new Study(20);
assertThat(study.getLimit()).isGreaterThan(0);
});
}
@Test
@EnabledOnOs(OS.WINDOWS)
void enabledOnOsTest() {
System.out.println("EnabledOnOs");
}
@Test
@DisabledOnOs(OS.WINDOWS)
void disabledOnOsTest() {
System.out.println("DisabledOnOs");
}
@Test
@EnabledOnJre(JRE.JAVA_8)
void enabledOnJreTest() {
System.out.println("JAVA_8");
}
@Test
@EnabledOnJre(JRE.OTHER)
void disabledOnJreTest() {
System.out.println("JRE_OTHER");
}