application test : junit5 - 커스텀 태그

This commit is contained in:
haerong22
2021-02-24 19:07:30 +09:00
parent 7c44dd71c4
commit b7f94f4356
3 changed files with 56 additions and 8 deletions

View File

@@ -0,0 +1,16 @@
package com.example.apptest;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Test
@Tag("fast")
public @interface FastTest {
}

View File

@@ -0,0 +1,16 @@
package com.example.apptest;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Test
@Tag("slow")
public @interface SlowTest {
}

View File

@@ -10,24 +10,40 @@ import static org.junit.jupiter.api.Assertions.*;
@DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class)
class StudyTest {
@Test
@DisplayName("tag test")
@Tag("fast")
void test_14() {
@FastTest
@DisplayName("custom tag test")
void test_16() {
System.out.println("fast");
Study study = new Study(10);
assertTrue(study.getLimit() > 0, () -> "limit 는 0보다 커야한다.");
}
@Test
@DisplayName("tag test")
@Tag("slow")
void test_13() {
@SlowTest
@DisplayName("custom tag test")
void test_15() {
System.out.println("slow");
Study study = new Study(10);
assertTrue(study.getLimit() > 0, () -> "limit 는 0보다 커야한다.");
}
// @Test
// @DisplayName("tag test")
// @Tag("fast")
// void test_14() {
// System.out.println("fast");
// Study study = new Study(10);
// assertTrue(study.getLimit() > 0, () -> "limit 는 0보다 커야한다.");
// }
//
// @Test
// @DisplayName("tag test")
// @Tag("slow")
// void test_13() {
// System.out.println("slow");
// Study study = new Study(10);
// assertTrue(study.getLimit() > 0, () -> "limit 는 0보다 커야한다.");
// }
// @Test
// @DisplayName("DisabledIfEnvironmentVariable test")
// @DisabledIfEnvironmentVariable(named = "TEST_ENV", matches = "KIM")