We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
직방 - 우리의 테스트에 Mockito 한잔
테스트 할 때 Spring에 의존성이 필요하다면 @MockBean을 사용하면 되고, 의존성 없는 로직을 테스트할 경우에는 @Mock을 사용하면 됩니다.
스텁(stubbing)은 어떤 로직을 가지고 있는 것이 아닌, 미리 지정한 값을 반환하는 것을 뜻함 when().then() 형식으로 사용 when() -> 호출할 조건 then() -> 반환할 값
@Mock List mockedList; // stubbing when(mockedList.get(0)).thenReturn("Hello"); when(mockedList.get(1)).thenThrow(new RuntimeException()); System.out.println(mockedList.get(0)); // "Hello" 출력 System.out.println(mockedList.get(1)); // runtime exception이 발생 System.out.println(mockedList.get(10)); // 10번째는 스텁을 하지 않았기 때문에 null이 출력됨
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Mockito
직방 - 우리의 테스트에 Mockito 한잔
알고리즘 - Stack, 아스키코드
The text was updated successfully, but these errors were encountered: