org.etlunit.StatusReporter Maven / Gradle / Ivy
package org.etlunit;
import org.etlunit.parser.ETLTestClass;
import org.etlunit.parser.ETLTestMethod;
import java.util.ArrayList;
import java.util.List;
public interface StatusReporter
{
enum test_completion_code
{
success,
failure,
warning,
error
}
class CompletionStatus
{
private TestExecutionError testExecutionError;
private final List assertionFailures = new ArrayList();
private final List assertionFailureIds = new ArrayList();
private final List testWarnings = new ArrayList();
private final List testWarningIds = new ArrayList();
private String expectedErrorId;
private List expectedFailureIds = new ArrayList();
private List expectedWarningIds = new ArrayList();
private boolean expectedErrorOverride = false;
private boolean expectedFailureOverride = false;
public void setExpectedErrorOverride(boolean expectedErrorOverride)
{
this.expectedErrorOverride = expectedErrorOverride;
}
public void setExpectedFailureOverride(boolean expectedFailureOverride)
{
this.expectedFailureOverride = expectedFailureOverride;
}
public String getExpectedErrorId()
{
return expectedErrorId;
}
public void setExpectedErrorId(String expectedErrorId)
{
this.expectedErrorId = expectedErrorId;
}
public void addExpectedFailureId(String expectedErrorId)
{
expectedFailureIds.add(expectedErrorId);
}
public void addExpectedFailureIds(List expectedErrorIds)
{
expectedFailureIds.addAll(expectedErrorIds);
}
public void addExpectedWarningId(String expectedErrorId)
{
expectedWarningIds.add(expectedErrorId);
}
public void addExpectedWarningIds(List expectedErrorIds)
{
expectedWarningIds.addAll(expectedErrorIds);
}
public TestExecutionError getError()
{
return testExecutionError;
}
public boolean hasError()
{
return testExecutionError != null;
}
public boolean hasFailures()
{
return hasError() || assertionFailures.size() != 0;
}
public List getAssertionFailures()
{
return assertionFailures;
}
public List getWarnings()
{
return testWarnings;
}
public void addWarning(TestWarning warn)
{
String warningId = warn.getWarningId();
if (!testWarningIds.contains(warningId))
{
testWarningIds.add(warningId);
}
testWarnings.add(warn);
}
public void addFailure(TestAssertionFailure failure)
{
String failureId = failure.getFailureId();
if (!assertionFailureIds.contains(failureId))
{
assertionFailureIds.add(failureId);
}
assertionFailures.add(failure);
}
public void setError(TestExecutionError err)
{
testExecutionError = err;
}
public String toString()
{
return "error=" + testExecutionError + ", failures=" + assertionFailures + ", warnings" + testWarnings;
}
public test_completion_code getTestResult()
{
test_completion_code testResult = null;
if (testExecutionError != null && expectedErrorId == null)
{
testResult = test_completion_code.error;
}
else if (assertionFailures.size() != 0)
{
testResult = test_completion_code.failure;
}
else if (testWarnings.size() != 0)
{
testResult = test_completion_code.warning;
}
else
{
testResult = test_completion_code.success;
}
switch (testResult)
{
case success:
return test_completion_code.success;
case warning:
return test_completion_code.success;
case failure:
case error:
if (expectedErrorOverride || expectedFailureOverride)
{
// success
return test_completion_code.success;
}
return testResult;
default:
throw new UnsupportedOperationException();
}
}
public List getExpectedWarningIds()
{
return expectedWarningIds;
}
public List getExpectedFailureIds()
{
return expectedFailureIds;
}
public List getTestWarningIds()
{
return testWarningIds;
}
public List getAssertionFailureIds()
{
return assertionFailureIds;
}
}
void scanStarted();
void scanCompleted();
void testsStarted(int numTestsSelected);
void testClassAccepted(ETLTestClass method);
void testMethodAccepted(ETLTestMethod method);
void testBeginning(ETLTestMethod method);
void testCompleted(ETLTestMethod method, CompletionStatus status);
void testsCompleted();
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy