프로젝트/PlayUs

6. Github Actions CI 에서의 영어 출력으로 인한 테스트 실패

han1693516 2025. 5. 14. 12:01

 

 

오늘도 CI 환경에서 다음과 같은 에러가 발생했다.

 

 

관련 코드는 다음과 같다. service 단에서의 LocalDateTime 을 @JsonFormat 을 통해 String 으로 변환 후, 이에 대한 테스트이다. 로컬에서는 문제없이 통과했지만 CI 에서는 실패해서 Locale 관련 설정을 찾아보았다. 

@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "M.d(E) a h:mm", timezone = "Asia/Seoul")
LocalDateTime matchDate,
@DisplayName("직관팟을 가져올 때, 날짜를 의도한 형식대로 변환해 반환할 수 있다.")
    @MethodSource("matchDateWithFormattedResult")
    @ParameterizedTest(name = "Date = {0}, formatted Date = {1}")
    void getPartiesByMatchId(LocalDateTime matchDate, String expectedFormattedDate) throws Exception {
        // given
        Long matchId = 1L;
        List<PartyAgeGroup> partyAges = List.of(PartyAgeGroup.AGE_10, PartyAgeGroup.AGE_20);
        List<String> partyThumbnailUrls = List.of("http://party-thumbnail", "http://party-thumbnail2.com");
        List<String> userThumbnailUrls = List.of("http://user-thumbnailUrl", "http://user2-thumbnailUrl");

        PartiesByMatchResponse response = PartiesByMatchResponse.of(1L, "title", PartyJoinMethod.RESERVATION, partyAges, PartyGender.MALE,
                "ZSJ", "남성", matchDate,
                10L, 14L, partyThumbnailUrls, userThumbnailUrls);

        List<PartiesByMatchResponse> result = List.of(response);

        given(partyReadOnlyService.getPartiesBy(any(Long.class)))
                .willReturn(result);


        // when // then
        mockMvc.perform(get("/party")
                        .param("matchId", String.valueOf(matchId))
                        .contentType(APPLICATION_JSON)
                        .with(authentication(token)))
                .andDo(print())
                .andExpect(status().isOk())
                .andExpect(jsonPath("$[0].matchDate").value(expectedFormattedDate));
    }

    private static Stream<Arguments> matchDateWithFormattedResult() {
        return Stream.of(
                Arguments.of(LocalDateTime.of(2025, 3, 22, 14, 0), "3.22(토) 오후 2:00"),
                Arguments.of(LocalDateTime.of(2025, 3, 22, 0, 0), "3.22(토) 오전 12:00"),
                Arguments.of(LocalDateTime.of(2025, 5, 1, 19, 30), "5.1(목) 오후 7:30"),
                Arguments.of(LocalDateTime.of(2025, 12, 15, 10, 5), "12.15(월) 오전 10:05"),
                Arguments.of(LocalDateTime.of(2025, 3, 23, 12, 0), "3.23(일) 오후 12:00"),
                Arguments.of(LocalDateTime.of(2025, 3, 23, 1, 0), "3.23(일) 오전 1:00"),
                Arguments.of(LocalDateTime.of(2025, 12, 31, 23, 59), "12.31(수) 오후 11:59"),
                Arguments.of(LocalDateTime.of(2026, 1, 1, 0, 0), "1.1(목) 오전 12:00"),
                Arguments.of(LocalDateTime.of(2025, 6, 15, 11, 59), "6.15(일) 오전 11:59"),
                Arguments.of(LocalDateTime.of(2025, 6, 15, 12, 0), "6.15(일) 오후 12:00"),
                Arguments.of(LocalDateTime.of(2025, 7, 20, 0, 0), "7.20(일) 오전 12:00"),
                Arguments.of(LocalDateTime.of(2025, 7, 20, 23, 59), "7.20(일) 오후 11:59")
        );
    }

 

 

build.gradle 아래에 다음 코드를 넣어서 해결했다!

test {
	systemProperty 'user.language', 'ko'
	systemProperty 'user.country', 'KR'
}