Skip to content

Commit

Permalink
cleans up code
Browse files Browse the repository at this point in the history
  • Loading branch information
Oliver Kuntze committed Sep 17, 2020
1 parent e13ca77 commit 66416f8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
12 changes: 8 additions & 4 deletions src/fitnesse/junit/JUnitXMLPerPageRunListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,14 @@ public void testFinished(Description description) throws Exception {
@Override
public void testFailure(Failure failure) throws Exception {
super.testFailure(failure);
if (failure.getException() instanceof AssertionError)
testResultRecorder.recordTestResult(getTestName(failure.getDescription()), 0, 1, 0, failure.getException(), getExecutionTime());
else
testResultRecorder.recordTestResult(getTestName(failure.getDescription()), 0, 0, 1, failure.getException(), getExecutionTime());
String testName = getTestName(failure.getDescription());
Throwable throwable = failure.getException();
long executionTime = getExecutionTime();
if (throwable instanceof AssertionError) {
testResultRecorder.recordTestResult(testName, 0, 1, 0, throwable, executionTime);
} else {
testResultRecorder.recordTestResult(testName, 0, 0, 1, throwable, executionTime);
}
}

/**
Expand Down
19 changes: 12 additions & 7 deletions src/fitnesse/junit/JUnitXMLPerPageTestListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,18 @@ public void afterTest(TestDescriptor testDescriptor, TestResult testResult) {
* @param result the result of the test
*/
protected void testFailure(TestDescriptor testDescriptor, TestResult result) {
String testName = testDescriptor.getName();
Throwable throwable = result.getException();
long executionTime = calculateExecutionTimeInSeconds(result);
try {
if (result.getException() instanceof AssertionError) {
testResultRecorder.recordTestResult(testDescriptor.getName(), 0, 1, 0, result.getException(), calculateExecutionTimeInSeconds(result));
if (throwable instanceof AssertionError) {
testResultRecorder.recordTestResult(testName, 0, 1, 0, throwable, executionTime);
} else {
testResultRecorder.recordTestResult(testDescriptor.getName(), 0, 0, 1, result.getException(), calculateExecutionTimeInSeconds(result));
testResultRecorder.recordTestResult(testName, 0, 0, 1, throwable, executionTime);
}
} catch (IOException e) {
throw new RuntimeException(e);
}

}

/**
Expand All @@ -109,11 +111,14 @@ protected void testFailure(TestDescriptor testDescriptor, TestResult result) {
* @param result the result of the test
*/
protected void testSkipped(TestDescriptor testDescriptor, TestResult result) {
String testName = testDescriptor.getName();
Throwable throwable = result.getException();
long executionTime = calculateExecutionTimeInSeconds(result);
try {
if (result.getException() instanceof AssertionError) {
testResultRecorder.recordTestResult(testDescriptor.getName(), 1, 0, 0, result.getException(), calculateExecutionTimeInSeconds(result));
if (throwable instanceof AssertionError) {
testResultRecorder.recordTestResult(testName, 1, 0, 0, throwable, executionTime);
} else {
testResultRecorder.recordTestResult(testDescriptor.getName(), 0, 0, 1, result.getException(), calculateExecutionTimeInSeconds(result));
testResultRecorder.recordTestResult(testName, 0, 0, 1, throwable, executionTime);
}
} catch (IOException e) {
throw new RuntimeException(e);
Expand Down

0 comments on commit 66416f8

Please sign in to comment.