Can you give me a use-case? I'm quite surprised that a null mock can be passed to EasyMock since the mock comes from the test.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2011-03-23
I'm trying to keep my tests as short and sharp as possible, so I moved mock-up validation to the tear-down method; @AfterMethod using TestNG. I write a test like thus:
@AfterMethod
public void verifyMockups()
{
EasyMock.verify(myProvider);
}
@Test
public void shouldGetAccount()
{
givenAnAccount();
givenAnObjectProvider();
givenACache();
If I add a test which doesn't use a provider, myProvider will be null, and the verification will fail, unless I add boilerplate code to check for null before validating.
I would like to avoid the boilerplate code.
/Roger
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Can you give me a use-case? I'm quite surprised that a null mock can be passed to EasyMock since the mock comes from the test.
I'm trying to keep my tests as short and sharp as possible, so I moved mock-up validation to the tear-down method; @AfterMethod using TestNG. I write a test like thus:
@AfterMethod
public void verifyMockups()
{
EasyMock.verify(myProvider);
}
@Test
public void shouldGetAccount()
{
givenAnAccount();
givenAnObjectProvider();
givenACache();
}
If I add a test which doesn't use a provider, myProvider will be null, and the verification will fail, unless I add boilerplate code to check for null before validating.
I would like to avoid the boilerplate code.
/Roger