Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reset test status on success and set the exception on abort #36356

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading