개요

조건에 따라 테스트 실행하기

class StudyTest {
		@Test
		public void create_new_study() throws Exception {
				// 해당 환경 변수의 값을 가져온다.
				String test_env = System.getenv("TEST_ENV");
				System.out.println(test_env);
				// 환경 변수의 값이 LOCAL 일 경우 아래 테스트 진행
				Assumptions.assumeTrue("LOCAL".equalsIgnoreCase(test_env));
		
				Study study = new Study(10);
				assertNotNull(study);
		}

		@Test
		@EnabledIfEnvironmentVariable(named = "TEST_ENV", matches = "LOCAL")
		public void create_new_study() throws Exception {
				Study study = new Study(10);
				assertNotNull(study);
		}

		@Test
		public void create_new_study() throws Exception {
				Assumptions.assumingThat("LOCAL".equalsIgnoreCase(test_env), () -> {
						System.out.println("LOCAL");
						Study study = new Study(10)
						assertNotNull(study);
				});

				Assumptions.assumingThat("DEV".equalsIgnoreCase(test_env), () -> {
						System.out.println("DEV");
						Study study = new Study(10);
						assertNotNull(study);
				});
		}

		@Test
		// @EnabledOnOs({OS.MAC, OS.WINDOWS})
		// @EnabledOnJre({JRE.JAVA_9, JRE.JAVA_10})
		public void create_new_study() throws Exception {
				Study study = new Study(10);
				assertNotNull(study);
		}
}