사용자 도구

사이트 도구


springframework:springboot:test

문서의 이전 판입니다!


SpringBoot Test

@SpringBootTest

테스트용 프라퍼티 지정

@SpringBootTest(properties = {"some.username=user", "some.password=pwd"},
                webEnvironment = SpringBootTest.WebEnvironment.NONE)

Unable to find a @SpringBootConfiguration, you need to use @ContextConfiguration or @SpringBootTest(classes=...) with your test

  • Unable to find a @SpringBootConfiguration, you need to use @ContextConfiguration or @SpringBootTest(classes=…) with your test 라는 오류가 발생한다면 @SpringBootApplication 애노테이션이 붙은 클래스가 존재하는 패키지의 하위 패키지에 테스트를 둬야 한다는 원칙을 어긴 것이다.
  • 예: a.b.c.Application 이라면, 테스트 클래스는 a.b.c 아래의 패키지에 존재해야한다. 만약 a.b.x 처럼 돼있는 패키지에 테스트 클래스가 존재하면 자동으로 @SpringBootApplication을 탐색하지 못한다.

@TestProperties

@TestPropertySource(locations="classpath:test.properties")
public class ExampleApplicationTests {
 
}
 
 
You can use @TestPropertySource
 
@TestPropertySource(
    properties = {
        "some.username=validate",
        "some.password=false"
    }
)

@WebFluxTest

참조

springframework/springboot/test.1549932669.txt.gz · 마지막으로 수정됨: 2019/02/12 09:51 저자 kwon37xi