24.03.06 13:10 작성
·
176
0
DB교체 후 MemberServiceIntegrationTest 시 자꾸 아래와 같은 오류가 발생합니다.
구글링을 해보니 async 들어가서 메세지 안뜨게 체크 해제하는 것과 여러 방법을 해봤는데 지속적으로 저 메세지가 뜹니다..ㅠㅠ
도움주시면 감사하겠습니다.
상세 오류 내용
. ____ _
/\\ / ___'_ __ (_)_ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v3.2.2)
2024-03-06T13:03:25.170+09:00 INFO 29080 --- [ main] h.h.S.MemberServiceIntegrationTest : Starting MemberServiceIntegrationTest using Java 17.0.10 with PID 29080 (started by wlwlg in C:\개인공부\Back-End\Spring\hello-spring\hello-spring)
2024-03-06T13:03:25.171+09:00 INFO 29080 --- [ main] h.h.S.MemberServiceIntegrationTest : No active profile set, falling back to 1 default profile: "default"
2024-03-06T13:03:26.078+09:00 INFO 29080 --- [ main] o.s.b.a.w.s.WelcomePageHandlerMapping : Adding welcome page: class path resource [static/index.html]
2024-03-06T13:03:26.510+09:00 INFO 29080 --- [ main] h.h.S.MemberServiceIntegrationTest : Started MemberServiceIntegrationTest in 1.536 seconds (process running for 2.262)
2024-03-06T13:03:26.549+09:00 INFO 29080 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2024-03-06T13:03:26.606+09:00 INFO 29080 --- [ main] com.zaxxer.hikari.pool.HikariPool : HikariPool-1 - Added connection conn0: url=jdbc:h2:tcp://localhost/~/test user=SA
2024-03-06T13:03:26.607+09:00 INFO 29080 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
Java HotSpot(TM) 64-Bit Server VM warning: Sharing is only supported for boot loader classes because bootstrap classpath has been appended
org.opentest4j.AssertionFailedError: Expected java.lang.IllegalStateException to be thrown, but nothing was thrown.
at org.junit.jupiter.api.AssertionFailureBuilder.build(AssertionFailureBuilder.java:152)
at org.junit.jupiter.api.AssertThrows.assertThrows(AssertThrows.java:73)
at org.junit.jupiter.api.AssertThrows.assertThrows(AssertThrows.java:35)
at org.junit.jupiter.api.Assertions.assertThrows(Assertions.java:3115)
at hello.hellospring.Service.MemberServiceIntegrationTest.중복_회원_예외(MemberServiceIntegrationTest.java:54)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
2024-03-06T13:03:27.222+09:00 INFO 29080 --- [ionShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated...
2024-03-06T13:03:27.227+09:00 INFO 29080 --- [ionShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed.
Process finished with exit code -1
답변 2
1
0
안녕하세요. wlwlgoyo님, 공식 서포터즈 코즈위버입니다.
메세지를 보면 IllegalStateException 이 발생해야 하나 아무 오류도 발생하지 않아 테스트에 실패하였습니다.
org.opentest4j.AssertionFailedError: Expected java.lang.IllegalStateException to be thrown, but nothing was thrown.
한 테스트 내에 회원 데이터를 중복으로 생성하였는지 확인해주세요.
해결이 안되실 경우 중복회원 점검 메서드 코드 및 테스트 코드를 첨부하여 주시기 바랍니다.
감사합니다.
2024. 03. 06. 13:47
답변 감사합니다! 중복으로 생성했는데 자꾸 오류가 뜹니다..ㅠㅠ
@Test public void 중복_회원_예외(){ //given Member member1=new Member(); member1.setName("spring"); Member member2=new Member(); member2.setName("spring"); //when memberService.join(member1); //예외처리가 잘되면 성공이 뜬다! 왜냐면 service단에서 예외처리 로직을 설정해놨기 때문이다. IllegalStateException e = assertThrows(IllegalStateException.class, () -> memberService.join(member2)); assertThat(e.getMessage()).isEqualTo("이미 존재하는 회원입니다."); /* try{ memberService.join(member2); fail(); }catch (IllegalStateException e){ //service단에서 예외처리 메세지가 동일한지 확인 assertThat(e.getMessage()).isEqualTo("이미 존재하는 회원입니다."); }*/ //then }