This is an automated email from the ASF dual-hosted git repository. benw pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/tapestry-5.git
commit 414646ebefe0ef9b4dafd5a20868202666c38083 Author: Ben Weidig <[email protected]> AuthorDate: Mon Mar 30 12:04:54 2026 +0200 SeleniumTestCase always write error report (HTML+screenshot) --- .../java/org/apache/tapestry5/test/SeleniumTestCase.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/tapestry-test/src/main/java/org/apache/tapestry5/test/SeleniumTestCase.java b/tapestry-test/src/main/java/org/apache/tapestry5/test/SeleniumTestCase.java index 286805f3b..b96d1c4a4 100644 --- a/tapestry-test/src/main/java/org/apache/tapestry5/test/SeleniumTestCase.java +++ b/tapestry-test/src/main/java/org/apache/tapestry5/test/SeleniumTestCase.java @@ -39,6 +39,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.testng.Assert; import org.testng.ITestContext; +import org.testng.ITestResult; import org.testng.annotations.AfterClass; import org.testng.annotations.AfterMethod; import org.testng.annotations.AfterTest; @@ -103,6 +104,8 @@ public abstract class SeleniumTestCase extends Assert implements Selenium private ITestContext testContext; + private boolean errorReportWritten = false; + /** * Starts up the servers for the entire test (i.e., for multiple TestCases). By placing <parameter> elements * inside the appropriate <test> (of your testng.xml configuration @@ -236,7 +239,6 @@ public abstract class SeleniumTestCase extends Assert implements Selenium } File ffProfileTemplate = new File(TapestryRunnerConstants.MODULE_BASE_DIR, "src/test/conf/ff_profile_template"); - // From https://forums.parasoft.com/discussion/5682/using-selenium-with-firefox-snap-ubuntu String osName = System.getProperty("os.name"); String snapProfileRoot = osName.contains("Linux") && new File("/snap/firefox").exists() @@ -481,6 +483,7 @@ public abstract class SeleniumTestCase extends Assert implements Selenium */ protected void writeErrorReport(String reportText) { + errorReportWritten = true; errorReporter.writeErrorReport(reportText); } @@ -498,6 +501,8 @@ public abstract class SeleniumTestCase extends Assert implements Selenium @BeforeMethod public void indicateTestMethodName(Method testMethod) { + errorReportWritten = false; + LOGGER.info("Executing " + testMethod); testContext.setAttribute(TapestryTestConstants.CURRENT_TEST_METHOD_ATTRIBUTE, testMethod); @@ -509,8 +514,14 @@ public abstract class SeleniumTestCase extends Assert implements Selenium } @AfterMethod - public void cleanupTestMethod() + public void cleanupTestMethod(ITestResult result) { + if (result.getStatus() == ITestResult.FAILURE && !errorReportWritten) + { + Throwable t = result.getThrowable(); + String message = t != null ? t.toString() : "Test failed"; + writeErrorReport(message); + } testContext.setAttribute(TapestryTestConstants.CURRENT_TEST_METHOD_ATTRIBUTE, null); }
