문제

I try to learn EasyMock 3.2 by refactoring tests using jMock. Excuse me if the answer is obvious, but currently I cannot find it. I know there is a 'strict' mock which detects if the order of expected calls is wrong. But I was surprised that I don't get an error if some expectations are left. Example:

// This test passes as expected

@Test
public void connectShouldPass() {
    expect(sessionMock.setTimeout(10000)).andReturn(true);
    replay(sessionMock);
    sessionMock.setTimeout(10000);
}

// Here I would expect an fail but it passes too

@Test
public void connectShouldPass() {
    expect(sessionMock.setTimeout(10000)).andReturn(true);
    expect(sessionMock.setTimeout(10000)).andReturn(true);
    replay(sessionMock);
    sessionMock.setTimeout(10000);
}

Is it possible to check (maybe in the @After method) if more expectations were defined than called? Thanx, Andi

도움이 되었습니까?

해결책

[OP found their own answer. Providing answer as an answer, rather than a comment]

EasyMock.verify(mock) does the job.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top