JUnit 4 error: reference to assertEquals is ambiguous

This is a somewhat confusing compilation failure that sometimes happen when you write unit tests using JUnit 4. This is an example code snippet that produces this error (result.getValue() returns an Integer object): assertEquals(12345, result.getValue()); And when you try to compile your project it produces a compilation error like this: /projects/myapp/src/test/java/org/myapp/MyTest.java:[88,8] reference to assertEquals is …

Continue reading

Mockito an alternative to JMock

I’ve used JMock for quite some time and I’ve found it to be a great and very useful mocking framework for unit testing. I was never quite happy with the syntax though; especially the part where you specify expectations.  Here’s a JMock snippet illustrating an expectation and a return value from a mocked object context.checking(new …

Continue reading