Thursday, August 03, 2006

JMock: JUnit4 support without extending MockObjectTestCase

Back in early June, I submitted a code for JMock to support JUnit 4 without extending MockObjectTestCase.

Recently, one person wrote a comment that it has been very helpful in his project.
I appreciate his comment very much and I am glad that the code is helping his project.

I wasn't expecting that the code would be used before it is added to the main jMock distribution. But since it may take a while for that to happen, I added a jar file also so that the code can be used immediately.

I use Eclipse. If I extend MockObjectTestCase and use JUnit4 annotation to indicate Test methods as one jMock mailing list thread says to get around the problem of using JUnit4 with jMock, Eclipse complains that no test method is found. It is because MockObjectTestCase extends the old JUnit TestCase class and Eclipse simply assumes that I am executing the old JUnit TestCase (3.8.1). Eclipse looks for a method prefixed with "test" in that case. And my test method using JUnit4 is not prefixed with "test" any more. (I use the method name to describe behavior.)
So my code for supporting JUnit4 without extending MockObjectTestCase is helping me very much as well.

No comments: