Test param value using EasyMock
Posted
by fmpdmb
on Stack Overflow
See other posts from Stack Overflow
or by fmpdmb
Published on 2010-05-06T17:04:58Z
Indexed on
2010/05/06
17:08 UTC
Read the original article
Hit count: 227
I'm attempting to write some unit tests using EasyMock and TestNG and have run into a question. Given the following:
void execute(Foo f) {
Bar b = new Bar()
b.setId(123);
f.setBar(b);
}
I'm trying to test that the Id of the Bar gets set accordingly in the following fashion:
@Test
void test_execute() {
Foo f = EasyMock.createMock(Foo.class);
execute(f);
Bar b = ?; // not sure what to do here
f.setBar(b);
f.expectLastCall();
}
In my test, I can't just call f.getBar()
and inspect it's Id because f
is a mock object. Any thoughts? Is this where I'd want to look at the EasyMock v2.5 additions andDelegateTo()
and andStubDelegateTo()
?
© Stack Overflow or respective owner