Skip to content

Commit

Permalink
[test] do not keep Screenshots for successful tests
Browse files Browse the repository at this point in the history
2MB artifact in I Builds
  • Loading branch information
EcljpseB0T authored and jukzi committed Sep 18, 2024
1 parent 6fb8fb3 commit dad3444
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -235,13 +235,17 @@ public void testObserveFocus() {
System.out.println("active shell (5): " + shell.getDisplay().getActiveShell());

System.out.println("Value (should be true): " + value.getValue());
Screenshots.takeScreenshot(getClass(), getClass().getSimpleName(), System.out);

assertTrue(value.getValue());

assertEquals(1, tracker.count);
assertFalse(tracker.event.diff.getOldValue());
assertTrue(tracker.event.diff.getNewValue());
try {
assertTrue(value.getValue());

assertEquals(1, tracker.count);
assertFalse(tracker.event.diff.getOldValue());
assertTrue(tracker.event.diff.getNewValue());
} catch (Exception | AssertionError e) {
String screenshot = Screenshots.takeScreenshot(getClass(), getClass().getSimpleName(), System.out);
e.addSuppressed(new Throwable("Screenshot written to " + screenshot));
throw e;
}
}

private void processDisplayQueue() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ public class ScreenshotTest {

@Test
public void testScreenshot() throws Exception {
takeScreenshot(ScreenshotTest.class, testName.getMethodName(), System.out);
String screenshot= takeScreenshot(ScreenshotTest.class, testName.getMethodName(), System.out);
new File(screenshot).delete();
}

@Test
Expand Down Expand Up @@ -73,7 +74,7 @@ public void testWindowsTaskManagerScreenshots() throws Exception {
System.out.println("* CTRL up " + display.post(event));

runEventQueue();
takeScreenshot(ScreenshotTest.class, testName.getMethodName() + 2, System.out);
String screenshot1= takeScreenshot(ScreenshotTest.class, testName.getMethodName() + 2, System.out);

event.type= SWT.KeyDown;
event.character= SWT.ESC;
Expand All @@ -83,7 +84,9 @@ public void testWindowsTaskManagerScreenshots() throws Exception {
System.out.println("* ESC up " + display.post(event));

runEventQueue();
takeScreenshot(ScreenshotTest.class, testName.getMethodName() + 3, System.out);
String screenshot2= takeScreenshot(ScreenshotTest.class, testName.getMethodName() + 3, System.out);
new File(screenshot1).delete();
new File(screenshot2).delete();
}

/**
Expand Down

0 comments on commit dad3444

Please sign in to comment.