Skip to content

Commit

Permalink
Revert "junit 5 400 error fix"
Browse files Browse the repository at this point in the history
This reverts commit 1aebb74.
  • Loading branch information
savkk committed Feb 15, 2023
1 parent 1aebb74 commit 0d4cf46
Showing 1 changed file with 18 additions and 34 deletions.
52 changes: 18 additions & 34 deletions qase-junit5/src/main/java/io/qase/junit5/QaseExtension.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

import io.qase.api.StepStorage;
import io.qase.api.config.QaseConfig;
import io.qase.api.services.QaseTestCaseListener;
import io.qase.client.model.ResultCreate;
import io.qase.client.model.ResultCreate.StatusEnum;
import io.qase.client.model.ResultCreateCase;
import io.qase.client.model.ResultCreateStepsInner;
import io.qase.api.services.QaseTestCaseListener;
import io.qase.junit5.guice.module.Junit5Module;
import lombok.AccessLevel;
import lombok.Getter;
Expand All @@ -31,7 +31,7 @@ public class QaseExtension implements TestExecutionListener {
private static final String REPORTER_NAME = "JUnit 5";

private final Set<TestIdentifier> startedTestIdentifiers =
new ConcurrentSkipListSet<>(Comparator.comparing(TestIdentifier::hashCode));
new ConcurrentSkipListSet<>(Comparator.comparing(TestIdentifier::hashCode));

@Getter(lazy = true, value = AccessLevel.PRIVATE)
private final QaseTestCaseListener qaseTestCaseListener = createQaseListener();
Expand All @@ -45,22 +45,6 @@ public void executionStarted(TestIdentifier testIdentifier) {
if (!testIdentifier.isTest()) {
return;
}
TestSource testSource = testIdentifier.getSource().orElse(null);
Method testMethod;
if (testSource instanceof MethodSource) {
testMethod = getMethod((MethodSource) testSource);
} else {
return;
}

Long caseId = getCaseId(testMethod);
String caseTitle = null;
if (caseId == null) {
caseTitle = getCaseTitle(testMethod);
}
if (caseId == null && caseTitle == null) {
return;
}
getQaseTestCaseListener().onTestCaseStarted();
startedTestIdentifiers.add(testIdentifier);
}
Expand All @@ -72,11 +56,11 @@ public void executionFinished(TestIdentifier testIdentifier, TestExecutionResult
}
TestSource testSource = testIdentifier.getSource().orElse(null);
Method testMethod = testSource instanceof MethodSource
? getMethod((MethodSource) testSource)
: null;
? getMethod((MethodSource) testSource)
: null;

getQaseTestCaseListener()
.onTestCaseFinished(resultCreate -> setupResultItem(resultCreate, testExecutionResult, testMethod));
.onTestCaseFinished(resultCreate -> setupResultItem(resultCreate, testExecutionResult, testMethod));
}

@Override
Expand All @@ -85,31 +69,31 @@ public void testPlanExecutionFinished(TestPlan testPlan) {
}

private void setupResultItem(
ResultCreate resultCreate, TestExecutionResult testExecutionResult, Method testMethod
ResultCreate resultCreate, TestExecutionResult testExecutionResult, Method testMethod
) {
Long caseId = getCaseId(testMethod);
String caseTitle = null;
if (caseId == null) {
caseTitle = getCaseTitle(testMethod);
}
StatusEnum status =
testExecutionResult.getStatus() == SUCCESSFUL ? StatusEnum.PASSED : StatusEnum.FAILED;
testExecutionResult.getStatus() == SUCCESSFUL ? StatusEnum.PASSED : StatusEnum.FAILED;
String comment = testExecutionResult.getThrowable()
.flatMap(throwable -> Optional.of(throwable.toString())).orElse(null);
.flatMap(throwable -> Optional.of(throwable.toString())).orElse(null);
Boolean isDefect = testExecutionResult.getThrowable()
.flatMap(throwable -> Optional.of(throwable instanceof AssertionError))
.orElse(false);
.flatMap(throwable -> Optional.of(throwable instanceof AssertionError))
.orElse(false);
String stacktrace = testExecutionResult.getThrowable()
.flatMap(throwable -> Optional.of(getStacktrace(throwable))).orElse(null);
.flatMap(throwable -> Optional.of(getStacktrace(throwable))).orElse(null);
LinkedList<ResultCreateStepsInner> steps = StepStorage.stopSteps();
resultCreate
._case(caseTitle == null ? null : new ResultCreateCase().title(caseTitle))
.caseId(caseId)
.status(status)
.comment(comment)
.stacktrace(stacktrace)
.steps(steps.isEmpty() ? null : steps)
.defect(isDefect);
._case(caseTitle == null ? null : new ResultCreateCase().title(caseTitle))
.caseId(caseId)
.status(status)
.comment(comment)
.stacktrace(stacktrace)
.steps(steps.isEmpty() ? null : steps)
.defect(isDefect);
}


Expand Down

0 comments on commit 0d4cf46

Please sign in to comment.