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

Issue #21 Alternative Version with AssertionError hierarchy #25

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
126 changes: 0 additions & 126 deletions src/main/java/org/opentest4j/AssertionFailedError.java

This file was deleted.

89 changes: 89 additions & 0 deletions src/main/java/org/opentest4j/AssertionFailedException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/*
* Copyright 2015-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.opentest4j;

import org.opentest4j.debug.DebugInformation;
import org.opentest4j.debug.DebuggableObject;

/**
* <p>
* {@code AssertionFailedException} is an <em>initial draft</em> for a common base class for test-related assertion
* failures.
* </p>
* <dl>
* <dt><strong>WARNING:</strong></dt>
* <dd>this is a <em>work in progress</em> and is therefore guaranteed to undergo heavy revisions in the near future
* based on community feedback.</dd>
* </dl>
* <p>
*
* @author Sam Brannen
* @author Marc Philipp
* @author Mark Michaelis
* @since 1.0
*/
public class AssertionFailedException extends AssertionError implements DebuggableObject {

private static final long serialVersionUID = 1L;
private final DebugInformation debugInformation;

public AssertionFailedException() {
this((DebugInformation) null);
}

public AssertionFailedException(String message) {
this(message, (DebugInformation) null);
}

public AssertionFailedException(String message, Throwable cause) {
this(message, null, cause);
}

public AssertionFailedException(Throwable cause) {
this((DebugInformation) null, cause);
}

public AssertionFailedException(DebugInformation debugInformation) {
this.debugInformation = debugInformation;
}

public AssertionFailedException(String message, DebugInformation debugInformation) {
super(message);
this.debugInformation = debugInformation;
}

public AssertionFailedException(String message, DebugInformation debugInformation, Throwable cause) {
super(message);
this.initCause(cause);
this.debugInformation = debugInformation;
}

public AssertionFailedException(DebugInformation debugInformation, Throwable cause) {
super(cause);
this.debugInformation = debugInformation;
}

@Override
public DebugInformation getDebugInformation() {
return this.debugInformation;
}

@Override
public boolean hasDebugInformation() {
return this.debugInformation != null;
}
}
78 changes: 78 additions & 0 deletions src/main/java/org/opentest4j/DebuggableException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/*
* Copyright 2015-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.opentest4j;

import org.opentest4j.debug.DebugInformation;
import org.opentest4j.debug.DebuggableObject;

/**
* A basic debuggable exception. That is an exception which might carry additional information for debugging purpose.
* Typical usage is to provide actual and expected values upon test failures.
*
* @author Mark Michaelis
* @since 1.0
*/
public class DebuggableException extends RuntimeException implements DebuggableObject {

private static final long serialVersionUID = 1405415156020390125L;
private final DebugInformation debugInformation;

public DebuggableException() {
this((DebugInformation) null);
}

public DebuggableException(String message) {
this(message, (DebugInformation) null);
}

public DebuggableException(String message, Throwable cause) {
this(message, null, cause);
}

public DebuggableException(Throwable cause) {
this((DebugInformation) null, cause);
}

public DebuggableException(DebugInformation debugInformation) {
this.debugInformation = debugInformation;
}

public DebuggableException(String message, DebugInformation debugInformation) {
super(message);
this.debugInformation = debugInformation;
}

public DebuggableException(String message, DebugInformation debugInformation, Throwable cause) {
super(message, cause);
this.debugInformation = debugInformation;
}

public DebuggableException(DebugInformation debugInformation, Throwable cause) {
super(cause);
this.debugInformation = debugInformation;
}

@Override
public DebugInformation getDebugInformation() {
return this.debugInformation;
}

@Override
public boolean hasDebugInformation() {
return this.debugInformation != null;
}
}
24 changes: 23 additions & 1 deletion src/main/java/org/opentest4j/IncompleteExecutionException.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package org.opentest4j;

import org.opentest4j.debug.DebugInformation;

/**
* {@link RuntimeException} used to indicate that the execution of a test
* was incomplete &mdash; for example, that the execution was entirely
Expand All @@ -26,9 +28,10 @@
*
* @author Johannes Link
* @author Sam Brannen
* @author Mark Michaelis
* @since 1.0
*/
public class IncompleteExecutionException extends RuntimeException {
public class IncompleteExecutionException extends DebuggableException {

private static final long serialVersionUID = 1L;

Expand All @@ -43,4 +46,23 @@ public IncompleteExecutionException(String message, Throwable cause) {
super(message, cause);
}

public IncompleteExecutionException(Throwable cause) {
super(cause);
}

public IncompleteExecutionException(DebugInformation debugInformation) {
super(debugInformation);
}

public IncompleteExecutionException(String message, DebugInformation debugInformation) {
super(message, debugInformation);
}

public IncompleteExecutionException(String message, DebugInformation debugInformation, Throwable cause) {
super(message, debugInformation, cause);
}

public IncompleteExecutionException(DebugInformation debugInformation, Throwable cause) {
super(debugInformation, cause);
}
}
Loading