인프런 커뮤니티 질문&답변

작성자 없음

작성자 정보가 삭제된 글입니다.

Practical Testing: 실용적인 테스트 가이드

Spring REST Docs

Cookie의 경우 RestDocs로 어떻게 해야할까요?

23.05.16 21:19 작성

·

881

1

강의 너무 잘듣고 사이드 프로젝트에 적용하고 있는데 cookie의 경우 restdocs로 어떻게 추출해야되는지 모르겠습니다.. 공식 문서에서는 requestCookies() 가 나와있는데 현재 저의 프로젝트에서는 적용이 안되네요.

 

저는 SpringBoot 2.6.12 버전이며 java 17, management의 경우 1.0.14 버전입니다.

답변 2

0

박우빈님의 프로필 이미지
박우빈
지식공유자

2023. 05. 18. 08:26

안녕하세요, Dev_ch님! :)

확인해보니 말씀하신 requestCookies()는 3.0 버전부터 추가된 스펙이네요. (관련 문서)
현재 버전에서 가장 간단하게는, 다음과 같이 요청에 쿠키를 실어서 Request Snippet에 표시해 주는 방법이 있을 것 같고요.

mockMvc.perform(
        get("/api/v1/products/selling")
            .cookie(new Cookie("key", "value"))
    )

추가적인 명시를 원하신다면 TemplatedSnippet 을 사용해서 custom한 Snippet을 만들어보는 방법도 있을 것 같아요 ㅎㅎ

원하시는 방향으로 잘 적용되면 좋겠네요!
감사합니다. :)

0

James Millere님의 프로필 이미지

2023. 05. 16. 23:39

Hi,

Given the information you have provided, it is difficult to provide a specific solution. However, I would recommend checking if there are any updates or changes to the RestDocs documentation that may be applicable to your project's version of SpringBoot. Additionally, you may want to consider seeking help from a SpringBoot community or support forum to see if someone has encountered a similar issue and has found a solution.

작성자 없음

작성자 정보가 삭제된 글입니다.

질문하기