I’ve seen today a non standard way of writing unit tests with JUnit,
instead of using the framework checks
Assert.assertTrue("Unexpected response encoding", text.length() >= 1);
a generic exception is thrown
if (text.length() < 1) {
throw new Exception("Unexpected response encoding");
}
I want to to convince the author to adopt the first style. Beside reason like verbosity, clarity of intent do you know what else can differ in these approaches?
Their treatment in report is different in two ways:
Assert.assertEquals, when failed, it reports bothexpectedandfoundvalues in the report along with the message.