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

add proper error reporting for old testng #1459

Merged
merged 1 commit into from
Jul 29, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import com.microsoft.java.test.runner.common.TestRunnerMessageHelper;

import org.testng.IConfigurationListener;
import org.testng.ISuite;
import org.testng.ISuiteListener;
import org.testng.ITestContext;
Expand All @@ -22,7 +23,9 @@

import java.util.Collection;

public class TestNGListener implements ISuiteListener, ITestListener, ITestNGListener {
public class TestNGListener
implements ISuiteListener, ITestListener, ITestNGListener, IConfigurationListener {
private ITestResult lastConfigFailure = null;

@Override
public void onTestStart(ITestResult result) {
Expand All @@ -46,6 +49,13 @@ public void onTestFailure(ITestResult result) {
public void onTestSkipped(ITestResult result) {
final Throwable throwable = result.getThrowable();
if (throwable != null) {
onTestFailure(result);
return;
} else if (this.lastConfigFailure != null) {
result.setThrowable(this.lastConfigFailure.getThrowable());
result.setStatus(this.lastConfigFailure.getStatus());
this.lastConfigFailure = null;

onTestFailure(result);
return;
}
Expand Down Expand Up @@ -83,4 +93,14 @@ private static <T> T getFirst(Collection<T> collection) {
return null;
}

@Override
public void onConfigurationSuccess(ITestResult itr) {}

@Override
public void onConfigurationFailure(ITestResult result) {
this.lastConfigFailure = result;
}

@Override
public void onConfigurationSkip(ITestResult result) {}
}