Skip to content

Commit

Permalink
Minor refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
HardNorth committed Oct 30, 2024
1 parent d0c8873 commit 00a6fc0
Showing 1 changed file with 13 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import com.epam.ta.reportportal.ws.model.log.SaveLogRQ;
import io.reactivex.Maybe;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.junit.jupiter.api.*;
import org.junit.jupiter.api.extension.*;
import org.opentest4j.TestAbortedException;
Expand Down Expand Up @@ -301,6 +300,17 @@ protected ItemStatus getExecutionStatus(@Nonnull final ExtensionContext context,
return IS_ASSUMPTION.test(throwable) ? SKIPPED : FAILED;
}

/**
* Returns a status of a test based on whether or not it contains an execution exception
*
* @param context JUnit's test context
* @return an {@link ItemStatus}
*/
@Nonnull
protected ItemStatus getExecutionStatus(@Nonnull final ExtensionContext context) {
return context.getExecutionException().map(t -> getExecutionStatus(context, t)).orElse(PASSED);
}

@Override
public void interceptDynamicTest(Invocation<Void> invocation, DynamicTestInvocationContext invocationContext,
ExtensionContext extensionContext) throws Throwable {
Expand Down Expand Up @@ -335,16 +345,7 @@ public void interceptTestTemplateMethod(Invocation<Void> invocation,
invocation.proceed();
}

/**
* Returns a status of a test based on whether or not it contains an execution exception
*
* @param context JUnit's test context
* @return an {@link ItemStatus}
*/
@Nonnull
protected ItemStatus getExecutionStatus(@Nonnull final ExtensionContext context) {
return context.getExecutionException().map(t -> getExecutionStatus(context, t)).orElse(PASSED);
}


@Override
public void afterTestExecution(ExtensionContext context) {
Expand Down Expand Up @@ -765,7 +766,7 @@ protected FinishTestItemRQ buildFinishTestRq(@Nonnull ExtensionContext context,
if (status != ItemStatus.PASSED && myException.isPresent()) {
String description = String.format(DESCRIPTION_TEST_ERROR_FORMAT,
createStepDescription(context, STEP),
ExceptionUtils.getStackTrace(myException.get()));
getStackTrace(myException.get()));
rq.setDescription(description);
}
ofNullable(status).ifPresent(s -> rq.setStatus(s.name()));
Expand Down

0 comments on commit 00a6fc0

Please sign in to comment.