On Fri, 28 Mar 2025 21:21:11 GMT, Kevin Rushforth <[email protected]> wrote:
>> Introduce a facility, in the form of JUnit5 annotation, to allow for
>> capturing a desktop screenshot of a failed test.
>>
>> The primary intent is to be able to debug an intermittent test case, rather
>> than wholesale addition of the new annotation to all the tests.
>>
>> A possible improvement could be to output a data URL
>>
>> `data:image/png;base64,iVBORw0KGgoAAAANSUhEU...`
>>
>> so it can be rendered in Safari (Chrome truncates the image possibly due to
>> following a url length limit)
>
> tests/system/src/test/java/test/util/ScreenCaptureTestWatcher.java line 77:
>
>> 75: public void testFailed(ExtensionContext extensionContext, Throwable
>> err) {
>> 76: err.printStackTrace();
>> 77: System.err.println(generateScreenshot("Screenshot:{", "}"));
>
> When does the `testFailed` method run? After a failing `@Test` method that
> throws the exception? What if there is more than one failing test? Ideally
> what we want is something that runs after all failing tests, but before the
> `@AfterEach` method.
Or... maybe we really do want to take a screen dump for each failing test in a
test class.
Also, what happens if one of the lifecycle methods is the one that throws the
error (e.g., `Before` `After`, etc)?
-------------
PR Review Comment: https://git.openjdk.org/jfx/pull/1746#discussion_r2019426801