I am moving an application from JUnit 3.x to JUnit 4.x. Of course, my hundreds of test classes now need to statically import org.junit.Assert methods, or directly reference org.junit.Assert for each assertion.
Most of these test classes extend a custom test case wrapper class (let's call it CompanyTestCase
) so it is feasible for me to do this
public void assertEquals(final Object expected, final Object actual)
{
org.junit.Assert.assertEquals(expected, actual);
}
but that seems somewhat clumsy, and smells bad to me in general. However the little devil on my shoulder argues that this is one reason people create custom test superclasses in the first place.
Help me understand the best way to tackle this problem -- I really don't want to believe that this post is the answer, mostly because I want to believe that Java is mature enough not to require boilerplate changes of this type (DRY, etc.).
As @blalasaadri points out, it would be nice to extend org.junit.Assert
, but, being a Spring/Mule application, the test case wrapper already extends org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests
.