Open GoogleCodeExporter opened 8 years ago
As a side note, if the test is rewritten as below, it still isn't failing like
it
should.
@RunWith(AtUnit.class)
@Container(Container.Option.GUICE)
public class myTest extends MyModule{
@Inject @Unit TestInterface testInterface;
Mockery mockery = new JUnit4Mockery();
final TestObject obj = mocker.mock(TestObject.class);
@Test
public void shouldFailTest() {
context.checking(new Expectations() {{
oneOf (obj).doTest();
}});
testInterface.testMethod(obj);
}
}
Original comment by lugieb...@gmail.com
on 1 Sep 2009 at 1:42
Sorry.. the code has a typo (the problem is still there, I just transcribed
incorrectly).
the test should be
mockery.checking(new Expect.....
not context.checking(new Expect....
Original comment by lugieb...@gmail.com
on 1 Sep 2009 at 9:48
I solved the issue for myself, but it appears that the problem lies in JMock
(and
perhaps the way AtUnit injects JMock mocks).
Problem has been narrowed down to:
If none of the mocked objects get called inside the execution method (i.e.
testInterface.testMethod(obj)), the test will pass no matter what expectations
are
set.
To use the example above, as long as doTest() does not touch 'obj', it will
pass any
expectation. If doTest() calls anything on 'obj', then the expectations will be
processed and the test will fail or pass accordingly
Original comment by lugieb...@gmail.com
on 1 Sep 2009 at 10:27
Original issue reported on code.google.com by
lugieb...@gmail.com
on 1 Sep 2009 at 1:36