[trouble shooting] 테스트 코드 Status expected:<200> but was:<403> ...

김동욱·2023년 9월 23일
0

trouble shooting

목록 보기
1/2

1번째 에러

JPA metamodel must not be empty!

1번째 해결 방법

@Configuration
@EnableJpaAuditing
public class JpaAuditingConfiguration {
}

2번째 해결 방법

@MockBean(JpaMetamodelMappingContext.class)

Spring boot 테스트 중에 위 오류를 만났습니다.
무슨 의미냐면


2번째 에러

boolean cannot be returned by tostring()

해결방법

when(factory.produce()).thenReturn(car);
-> 
doReturn(car).when(factory).produce();

변경해주면 된다.


3번째 에러

java.lang.AssertionError: Status expected:<200> but was:<403>

다음은 오류입니다.

mockMvc.perform(
.with(csrf()); // 추가해줌
)

4번째 에러

 Failed to load ApplicationContext

jwt필터 문제

 @MockBean
 Private JwtService jwtService;

추가

profile
안녕하세요. 공부해요

0개의 댓글