Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add supplementary Javadoc #914

Merged
merged 1 commit into from May 14, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/main/java/junit/framework/AssertionFailedError.java
Expand Up @@ -6,10 +6,19 @@
public class AssertionFailedError extends AssertionError {

private static final long serialVersionUID = 1L;


/**
* Constructs a new AssertionFailedError without a detail message.
*/
public AssertionFailedError() {
}

/**
* Constructs a new AssertionFailedError with the specified detail message.
* A null message is replaced by an empty String.
* @param message the detail message. The detail message is saved for later
* retrieval by the {@code Throwable.getMessage()} method.
*/
public AssertionFailedError(String message) {
super(defaultString(message));
}
Expand Down
17 changes: 14 additions & 3 deletions src/main/java/junit/framework/TestFailure.java
Expand Up @@ -5,7 +5,7 @@


/**
* A <code>TestFailure</code> collects a failed test together with
* A {@code TestFailure} collects a failed test together with
* the caught exception.
*
* @see TestResult
Expand All @@ -14,7 +14,6 @@ public class TestFailure {
protected Test fFailedTest;
protected Throwable fThrownException;


/**
* Constructs a TestFailure with the given test and exception.
*/
Expand Down Expand Up @@ -44,18 +43,30 @@ public Throwable thrownException() {
public String toString() {
return fFailedTest + ": " + fThrownException.getMessage();
}


/**
* Returns a String containing the stack trace of the error
* thrown by TestFailure.
*/
public String trace() {
StringWriter stringWriter = new StringWriter();
PrintWriter writer = new PrintWriter(stringWriter);
thrownException().printStackTrace(writer);
return stringWriter.toString();
}

/**
* Returns a String containing the message from the thrown exception.
*/
public String exceptionMessage() {
return thrownException().getMessage();
}

/**
* Returns {@code true} if the error is considered a failure
* (i.e. if it is an instance of {@code AssertionFailedError}),
* {@code false} otherwise.
*/
public boolean isFailure() {
return thrownException() instanceof AssertionFailedError;
}
Expand Down