diff --git a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_custom_StyledText.java b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_custom_StyledText.java index 21765b99a4..e604ad0696 100644 --- a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_custom_StyledText.java +++ b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_custom_StyledText.java @@ -103,13 +103,8 @@ public class Test_org_eclipse_swt_custom_StyledText extends Test_org_eclipse_swt private boolean listenerCalled; private boolean listener2Called; -@Rule public TestWatcher screenshotRule = new TestWatcher() { - @Override - protected void failed(Throwable e, org.junit.runner.Description description) { - super.failed(e, description); - Screenshots.takeScreenshot(description.getTestClass(), description.getMethodName()); - } -}; +@Rule +public TestWatcher screenshotRule = Screenshots.onFailure(); @Override @Before diff --git a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_custom_StyledText_multiCaretsSelections.java b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_custom_StyledText_multiCaretsSelections.java index dfa31a8c01..b04c25230e 100644 --- a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_custom_StyledText_multiCaretsSelections.java +++ b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_custom_StyledText_multiCaretsSelections.java @@ -40,13 +40,7 @@ public class Test_org_eclipse_swt_custom_StyledText_multiCaretsSelections { @Rule - public TestWatcher screenshotRule = new TestWatcher() { - @Override - protected void failed(Throwable e, org.junit.runner.Description description) { - super.failed(e, description); - Screenshots.takeScreenshot(description.getTestClass(), description.getMethodName()); - } - }; + public TestWatcher screenshotRule = Screenshots.onFailure(); Shell shell; StyledText text; diff --git a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Tree.java b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Tree.java index 0ad17d53a0..e0b7732dc6 100644 --- a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Tree.java +++ b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Tree.java @@ -38,6 +38,7 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.TestName; +import org.junit.rules.TestWatcher; /** * Automated Test Suite for class org.eclipse.swt.widgets.Tree @@ -915,6 +916,9 @@ public void test_disposeItemNotTriggerSelection() { assertFalse(selectionCalled[0]); } +@Rule +public TestWatcher screenshotRule = Screenshots.onFailure(); + @Test public void test_Virtual() { tree.dispose(); @@ -964,7 +968,6 @@ public void test_Virtual() { } // temp code to capture screenshot if (SwtTestUtil.isCocoa) { - Screenshots.takeScreenshot(getClass(), testName.getMethodName()); // check if setData is called for root item assertTrue("SetData not called for top item", top[0] != null); }