Tuesday, 10 September 2013

How can I run unit tests with Maven as if they are in a JAR?

How can I run unit tests with Maven as if they are in a JAR?

We recently had a bug caused by some code assuming that a classpath
resource could be opened as if it were a regular file. This code was
covered by unit tests which passed, because that assumption happens to
hold both in Maven and Eclipse. But in production, that code was in a JAR
in the service's WAR, and obviously didn't work.
We fixed the bug but I'm not quite satisfied because I can't see how to
ensure that it doesn't happen again.

No comments:

Post a Comment