this.name = name;
}
+ /**
+ * This constructor can be used if you require a no-param constructor. In
+ * this case, you are allowed to set the name manually via
+ * {@link TestCase#setName}.
+ */
+ protected TestCase() {
+ this("no name");
+ }
+
/**
* Setup the test (called before the test is run).
*
return name;
}
+ /**
+ * The test name.
+ *
+ * @param name
+ * the new name (internal use only)
+ *
+ * @return this (so we can chain and so we can initialize it in a member
+ * variable if this is an anonymous inner class)
+ */
+ protected TestCase setName(String name) {
+ this.name = name;
+ return this;
+ }
+
/**
* Actually do the test.
*
*
* @param reason
* the failure reason
+ *
* @throws AssertException
* every time
*/
public void fail(String reason) throws AssertException {
+ fail(reason, null);
+ }
+
+ /**
+ * Force a failure.
+ *
+ * @param reason
+ * the failure reason
+ * @param e
+ * the exception that caused the failure (can be NULL)
+ *
+ * @throws AssertException
+ * every time
+ */
+ public void fail(String reason, Exception e) throws AssertException {
throw new AssertException("Failed!" + //
- reason != null ? "\n" + reason : "");
+ reason != null ? "\n" + reason : "", e);
}
/**