• Maven Test Problem with Surefire

    I’ve started porting a few apps at work in to Maven to do the final test run. One of the first systems I am importing is our credit card processing system.

    Everything went fine until I tried to run the mvn package command to bundle up the web app. I got the following error:

    org.apache.maven.surefire.testset.TestSetFailedException: Unable to instantiate POJO \'class test.com.westgateresorts.paymentprocessing.creditcard.testdata.TestDataFactory'

    Obviously, the surefire test plugin couldn’t instantiate the class, but I couldn’t understand why this would be a problem since the class was on the test classpath. I looked on Google and didn’t find anything interesting.

    Then, I remembered something about the surefire plugin running every class named “**/Test*.java”, “**/*Test.java”, or “**/*TestCase.java”. What was happening was that the plugin was trying to instantiate this class as a test case, when in fact it’s just a convenience class we use to provide test data. Unfortunately, this was one of our early Java projects, and we didn’t follow all the proper naming conventions for our test classes and their support classes.

    Not a problem, though – there is a way to configure inclusion and exclusion of tests in the surefire plugin. I’m going to leave this until next week, though, since it’s FRIDAY!

    Category: Uncategorized | Tags: