Java Ninja Chronicles By Norris Shelton

Things I learned in the pursuit of code

I’m used to writing JUnit test classes with my Spring classes. I was working on some very old code that had no Spring at all. It was just a normal class that needed to be tested. I didn’t include any of the annotations that I normally have at the top of a class, but IntelliJ couldn’t see them. When I ran the class with Maven, it did run the tests, but also ran the tests annotated with @Ignore. What the heck. I had to do some digging and saw that you need to add a @RunWith to the class declaration.

@RunWith(BlockJUnit4ClassRunner.class)
public class W2GPdfTest {
    // normal test methods
}

Problem solved.

December 17th, 2015

Posted In: Java, java ninja, Javaninja, JUnit

Leave a Reply

Your email address will not be published. Required fields are marked *

LinkedIn Auto Publish Powered By : XYZScripts.com