사용자 도구

사이트 도구


springframework:springboot:test

차이

문서의 선택한 두 판 사이의 차이를 보여줍니다.

차이 보기로 링크

양쪽 이전 판 이전 판
다음 판
이전 판
다음 판 양쪽 다음 판
springframework:springboot:test [2019/01/22 15:38]
kwon37xi [@WebFluxTest]
springframework:springboot:test [2020/07/08 13:40]
kwon37xi [Unable to find a @SpringBootConfiguration, you need to use @ContextConfiguration or @SpringBootTest(classes=...) with your test]
줄 1: 줄 1:
 ====== SpringBoot Test ====== ====== SpringBoot Test ======
   * [[springframework:springboot|SpringBoot]] Test   * [[springframework:springboot|SpringBoot]] Test
 +  * [[kotlin:junit5|Kotlin JUnit 5]]
   * [[https://github.com/spring-projects/spring-boot/tree/master/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure|Spring Boot Test Autoconfigure]] 여기에서 각종 test 자동화 Annotation을 확인할 수 있다.   * [[https://github.com/spring-projects/spring-boot/tree/master/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure|Spring Boot Test Autoconfigure]] 여기에서 각종 test 자동화 Annotation을 확인할 수 있다.
  
줄 13: 줄 14:
   * ''Unable to find a @SpringBootConfiguration, you need to use @ContextConfiguration or @SpringBootTest(classes=...) with your test'' 라는 오류가 발생한다면 ''@SpringBootApplication'' 애노테이션이 붙은 클래스가 존재하는 패키지의 하위 패키지에 테스트를 둬야 한다는 원칙을 어긴 것이다.   * ''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''을 탐색하지 못한다.   * 예: ''a.b.c.Application'' 이라면, 테스트 클래스는 ''a.b.c'' 아래의 패키지에 존재해야한다. 만약 ''a.b.**x**'' 처럼 돼있는 패키지에 테스트 클래스가 존재하면 자동으로 ''@SpringBootApplication''을 탐색하지 못한다.
 +  * **보통 ''@SpringBootApplication''이 존재하지않는 Library 성 모듈의 경우 발생한다.
 +
 +=== 해결 ===
 +  * 테스트에  ''@EnableAutoConfiguration'' 추가,
 +  * 테스트 ''resources''에 ''application.yml'' 필요(혹은 명시적 지정)
 +  * ''@SpringBootTest(classes = config 클래스 목록 지정)''
  
 ===== @TestProperties ===== ===== @TestProperties =====
줄 39: 줄 46:
     * [[https://github.com/spring-projects/spring-boot/issues/15070|When using WebFluxTest, WebTestClient's codecs are not customized breaking JSON (de)serialisation that relies on Module-provided functionality · Issue #15070 · spring-projects/spring-boot]]     * [[https://github.com/spring-projects/spring-boot/issues/15070|When using WebFluxTest, WebTestClient's codecs are not customized breaking JSON (de)serialisation that relies on Module-provided functionality · Issue #15070 · spring-projects/spring-boot]]
   * [[java:spock|Spock]]에서 호출시 ''uri(...)'' 를 호출하고 나면 Generic Type을 놓치는 현상 발생([[:intellij_idea|IntelliJ IDEA]] 버그일 수 있음). 무시하고 계속 개발.   * [[java:spock|Spock]]에서 호출시 ''uri(...)'' 를 호출하고 나면 Generic Type을 놓치는 현상 발생([[:intellij_idea|IntelliJ IDEA]] 버그일 수 있음). 무시하고 계속 개발.
 +  * [[http://www.mkyong.com/spring-boot/spring-webflux-test-timeout-on-blocking-read-for-5000-milliseconds/|Spring WebFlux Test – Timeout on blocking read for 5000 MILLISECONDS – Mkyong.com]]
 ===== 참조 ===== ===== 참조 =====
   * [[http://www.baeldung.com/spring-boot-testing|Testing in Spring Boot | Baeldung]]   * [[http://www.baeldung.com/spring-boot-testing|Testing in Spring Boot | Baeldung]]
줄 49: 줄 57:
   * [[https://content.pivotal.io/springone-platform-2017/test-driven-development-with-spring-boot-sannidhi-jalukar-madhura-bhave|Test Driven Development with Spring Boot - Sannidhi Jalukar, Madhura Bhave]]   * [[https://content.pivotal.io/springone-platform-2017/test-driven-development-with-spring-boot-sannidhi-jalukar-madhura-bhave|Test Driven Development with Spring Boot - Sannidhi Jalukar, Madhura Bhave]]
   * [[https://grokonez.com/testing/springboot-webflux-test-webfluxtest|SpringBoot WebFlux Test - @WebFluxTest - grokonez]]   * [[https://grokonez.com/testing/springboot-webflux-test-webfluxtest|SpringBoot WebFlux Test - @WebFluxTest - grokonez]]
 +  * [[http://www.mkyong.com/spring-boot/spring-boot-junit-5-mockito/|Spring Boot + JUnit 5 + Mockito – Mkyong.com]]
springframework/springboot/test.txt · 마지막으로 수정됨: 2022/08/31 16:02 저자 kwon37xi