Wednesday, February 2, 2011

Enable Assertions with JUnit Tests in IDEA

My test cases have recently been converted from TestNG to JUnit4, and to my surprise every single test I wrote from that point forward passed without a problem - if I ran the tests in my Intellij IDEA 9.0.4 IDE. Mysteriously, executing them via Maven did not have that same result (whether from command line or from IDEA). As it turns out - apparently JDK assertions are enabled by default when I use TestNG in IDEA, but not so much when using JUnit.

Fix this problem by setting the -ea VM argument for all existing tests, and setting that as a default for JUnit tests created from this point forward.

Arrrggghhhh.

No comments:

Post a Comment