본문 바로가기
SpringBoot

Java Conditional Unit Test

by ByteBridge 2022. 5. 21.
반응형
@Test
@Disabled("Don't run until JIRA #123 is resolved")
void testDisabled(){
    //
}

@Test
@EnabledOnOs(OS.WINDOWS)
void testForWindowsOnly(){
    
}

@Test
@EnabledOnOs(OS.MAC)
void testForMacOnly(){
    
}

@Test
@EnabledOnOs({OS.MAC,OS.WINDOWS})
void testForMacAndWindowsOnly(){
    
}

@Test
@EnabledOnOs(OS.LINUX)
void testForLinuxOnly(){
    
}

@Test
@EnabledOnJre(JRE.JAVA_17)
void testForJava17(){
    
}

@Test
@EnabledOnJre(JRE.JAVA_13)
void testForJava13(){
    
}

@Test
@EnabledOnJreRange(min=JRE.JAVA_13,max=JRE.JAVA_18)
void testForJavaRange(){
    
}

@Test
@EnabledOnJreRange(min=JRE.JAVA_11)
void testForJavaRangeMin(){
    
}

@Test
//intellij or system environment variable => DEV_ENV=DEV
@EnabledIfEnvironmentVariable(named="GAVIN_ENV", matches="DEV") 
void testOnlyForDevEnvironment(){
    
}

@Test
//intellij build and run => -ea -DGAVIN_SYS_PROP=CI_CD_DEPLOY
@EnabledIfSystemProperty(named="GAVIN_SYS_PROP", matches="CI_CD_DEPLOY")
void testOnlyForSystemProperty(){
    
}
반응형

'SpringBoot' 카테고리의 다른 글

Spring boot Test with Mockito  (0) 2022.05.22
Unit Test - ParameterizedTest  (0) 2022.05.21
spring aop  (0) 2021.11.07
Spring mvc async rest api  (0) 2021.11.07
Spring mvc async rest api  (0) 2021.11.07