EasyMock - Expecting an Explicit Number of Calls
모하니?/Coding : 2008. 3. 1. 11:53
같은 메소드 호출을 여러번 하는 경우 그런 행위를 녹화하기 위해서, 메소드를 여러번 호출할 수도 있지만.
이런 코드를 expectLastCall().times(3); 를 사용해서 코드를 줄일 수 있다.
public void testAddAndChangeDocument() {
mock.documentAdded("Document");
mock.documentChanged("Document");
mock.documentChanged("Document");
mock.documentChanged("Document");
replay(mock);
classUnderTest.addDocument("Document", new byte[0]);
classUnderTest.addDocument("Document", new byte[0]);
classUnderTest.addDocument("Document", new byte[0]);
classUnderTest.addDocument("Document", new byte[0]);
verify(mock);
}
이런 코드를 expectLastCall().times(3); 를 사용해서 코드를 줄일 수 있다.
public void testAddAndChangeDocument() {
mock.documentAdded("Document");
mock.documentChanged("Document");
expectLastCall().times(3);
replay(mock);
classUnderTest.addDocument("Document", new byte[0]);
classUnderTest.addDocument("Document", new byte[0]);
classUnderTest.addDocument("Document", new byte[0]);
classUnderTest.addDocument("Document", new byte[0]);
verify(mock);
}
'모하니? > Coding' 카테고리의 다른 글
EasyMock - Relaxing Call Counts (0) | 2008.03.01 |
---|---|
EasyMock - Changing Behavior for the Same Method Call (0) | 2008.03.01 |
EasyMock - Creating Return Values or Exceptions (0) | 2008.03.01 |
EasyMock - Working with Exceptions (0) | 2008.03.01 |
EasyMock - Specifying Return Values (0) | 2008.03.01 |
EasyMock - Expecting an Explicit Number of Calls (2) | 2008.03.01 |
HibernateExceptionToDataAccessExceptionApsect (2) | 2008.02.22 |
HibernateExceptionToDataAccessExceptionApsect 구상 중 (2) | 2008.02.22 |
EasyMock으로 클래스의 Mock 객체 만들기 (0) | 2008.02.06 |
99% Line Coverage (0) | 2008.01.23 |
하이버 + 스프링 관련 XML Template (2) | 2008.01.21 |
EasyMock 시리즈군요.. ㅎㅎ
질문이 있는데. ㅎㅎ
넹ㅋㅋ 정리하다가 데이트 다녀왔어요.
이제 다시 마저 정리 시작합니다.
어떤 질문이신데요?ㅋㅋ