게시글 작성 테스트
처음으로 시도한 방법은 다음과 같다.
하지만 여전히 제대로 동작하지 않았고 또 다른 방법을 찾아보아야 했다.
시도한 다른 방법은 BeforeAll을 사용해서 미리 인코딩을 해주는 것이다.
@BeforeAll
public void setup() {
this.mockMvc = MockMvcBuilders.webAppContextSetup(ctx)
.addFilters(new CharacterEncodingFilter("UTF-8", true)) // 필터 추가
.alwaysDo(print())
.build();
}
# test/resources/application.yml
server:
servlet:
encoding:
force-response: true
하지만 이 방법을 사용하자 또 다른 오류가 발생하였다.
org.junit.platform.commons.JUnitException: @BeforeAll method '...' must be static unless the test class is annotated with @TestInstance(Lifecycle.PER_CLASS)