티스토리 뷰
반응형
import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = WebApplication.class)
public class SwgDatabaseTest {
@Autowired
private UserService userService;
@Test
public void test(){
System.out.println("1234");
}
}
- 위와 같이 테스트 코드를 작성하고 돌려보니 아래 에러가 출력되었다.
11월 24, 2020 12:46:11 오후 org.junit.vintage.engine.descriptor.RunnerTestDescriptor warnAboutUnfilterableRunner
경고: Runner org.junit.internal.runners.ErrorReportingRunner (used on class SwgDatabaseTest) does not support filtering and will therefore be run completely.
org.junit.runners.model.InvalidTestClassError: Invalid test class 'SwgDatabaseTest':
1. No runnable methods
at org.junit.runners.ParentRunner.validate(ParentRunner.java:525)
at org.junit.runners.ParentRunner.<init>(ParentRunner.java:92)
-
구글링 해보니, junit4와 junit5에서 제공되는 클래스를 혼용해서 나온 에러였다ㅠ
-
junit5에서는 @RunWith 어노테이션을 지원하지 않는다. 대신 @ExtendWith 지원한다.
- 따라서 org.junit.jupiter.api.Test 을 사용할 경우에는 @ExtendWith를 사용해줘야한다.
-
junit4를 사용하려면 org.junit.jupiter.api.Test -> import org.junit.Test; 으로 변경해주면 된다.
- junit5 기준으로 수정된 코드
import com.swg.WebApplication;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import java.util.Date;
@ExtendWith(SpringExtension.class)
@SpringBootTest(classes = WebApplication.class)
public class SwgDatabaseTest {
@Test
public void test() {
System.out.println("test");
}
}
- junit4 기준으로 수정된 코드
import com.swg.WebApplication;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import java.util.Date;
@ExtendWith(SpringExtension.class)
@SpringBootTest(classes = WebApplication.class)
public class SwgDatabaseTest {
@Test
public void test() {
System.out.println("test");
}
}
- junit5
import com.swg.WebApplication;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import java.util.Date;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = WebApplication.class)
public class SwgDatabaseTest {
@Test
public void test() {
System.out.println("test");
}
}
반응형
'[기타]' 카테고리의 다른 글
[표기법] 파스칼 표기법(PascalCase), 카멜 표기법(CamelCase) (0) | 2020.12.10 |
---|---|
[Gradle] lombok, error: cannot find symbol 에러 (0) | 2020.12.06 |
[Gradle] no tests found for given includes (0) | 2020.11.24 |
[리눅스] 개행 문자 제거 (0) | 2020.11.20 |
[intellij] Unable to save settings: Failed to save settings. Please restart IntelliJ IDEA (2) | 2020.11.19 |
댓글
반응형
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
TAG
- Executor
- ThreadPool
- JAVA8
- codepoint
- 파스칼 표기법
- aspectj
- java11
- junit5
- JetBrains Mono
- java
- Mockito
- spring
- Jenkins
- hot-deploy
- IntelliJ
- jdk13
- 한글깨짐
- spring-security
- JUnit
- Thread
- Visual Studio 2022
- chmod
- Redis
- 확인창
- JPA
- 카멜 표기법
- jdk12
- thread priority
- gradle
- sgw
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
글 보관함