Skip to content

[ETC] 테스트코드 작성 시 만날 수 있는 오류와 해결 #9

@2eungwoo

Description

@2eungwoo

🖥️ Descriptions

1. Argument(s) are different: Wanted: Actual invocations have different arguments:

  • 로직에서 작성한 코드로부터 출력되는 값과 테스트 코드에서 출력되는 값은 일치하는데, 객체의 실제 멤버변수 값을 비교하는게 아니라 참조 값을 비교하기 때문에 argument가 다르다고 뜨는 것

2. postman 테스트에서는 response body 나오는데, 테스트코드에서 돌리면 response body가 null일때

  • 역시 참조값이 달라서 발생
    1. ResonseDto에서 생성자 미스 실수(생성자 없으니까 response body로 안나오는거임)
    1. mocking 실수. 검증하는 메소드 인자에 정확한 값이 아니라 any를 넣어서 해결

📖 Research (선택)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Reference

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions