Skip to content

Commit

Permalink
Reset test status on success and set the exception on abort
Browse files Browse the repository at this point in the history
Fixes #36250
  • Loading branch information
gsmet committed Oct 25, 2023
1 parent a36b6a6 commit 38461d0
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,16 @@ public void testFailed(ExtensionContext context, Throwable cause) {
markTestAsFailed(context, cause);
}

@Override
public void testSuccessful(ExtensionContext context) {
markTestAsSuccessful(context);
}

@Override
public void testAborted(ExtensionContext context, Throwable cause) {
markTestAsAborted(context, cause);
}

protected QuarkusTestExtensionState getState(ExtensionContext context) {
ExtensionContext.Store store = getStoreFromContext(context);
QuarkusTestExtensionState state = store.get(QuarkusTestExtensionState.class.getName(), QuarkusTestExtensionState.class);
Expand Down Expand Up @@ -92,4 +102,18 @@ protected void markTestAsFailed(ExtensionContext context, Throwable throwable) {
state.setTestFailed(throwable);
}
}

protected void markTestAsSuccessful(ExtensionContext context) {
QuarkusTestExtensionState state = getState(context);
if (state != null) {
state.setTestSuccessful();
}
}

protected void markTestAsAborted(ExtensionContext context, Throwable throwable) {
QuarkusTestExtensionState state = getState(context);
if (state != null) {
state.setTestAborted(throwable);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ public void close() throws IOException {
}
}

protected void setTestSuccessful() {
setTestFailed(null);
}

protected void setTestAborted(Throwable failure) {
setTestFailed(failure);
}

protected void setTestFailed(Throwable failure) {
try {
this.testErrorCause = failure;
Expand Down

0 comments on commit 38461d0

Please sign in to comment.