Details
-
Type:
Improvement
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: FEST-Swing 1.2a2
-
Fix Version/s: FEST-Swing 1.2rc
-
Component/s: Swing
-
Labels:None
Description
We are trying to use the GUITestRunner in order to further track down test failures. We observed however two problems with this approach, that we solved by creating our own test runner. I wonder however, if parts of this should not be integrated into the shipped version, because others may observe the same problems ![]()
- Running GUI test suites with ant and forkmode true:
When invoking a bigger test suite with fork mode set to true, each test class is executed in its own jvm. This causes however the GUITestRunner to clean sweap the image folder. Therefore, only the last test in the suite has a chance to show a failure screenshot. We solved this by parametrizing the image directory and delegating the cleanup to the actual ant task.
- Take the screenshot before the "After" method is run
Most of our tests create the GUI component under test in the Before method, perform the actual test in the Test method and dispose the component in the After method. Since the screenshot is however taken after the last After method has been executed, our screenshots usually show an empty desktop
We solved this by creating our own test runner that actually wraps the bare test methods, i. e.
@Override protected List<FrameworkMethod> getChildren() { List<FrameworkMethod> testMethods = super.getChildren(); List<FrameworkMethod> wrappedMethods = new ArrayList<FrameworkMethod>(); for (final FrameworkMethod method : testMethods) { wrappedMethods.add(new FrameworkMethod(method.getMethod()) { @Override public Object invokeExplosively(Object target, Object... params) throws Throwable { try { return super.invokeExplosively(target, params); } catch (Throwable e) { takeScreenshot(method); throw e; } } }); } return wrappedMethods; }
There is no need to override the run method any more.
I too find the need to take screen shots after the @Test method but before the @After methods.
But I believe that a cleaner approach is to override the methodBlock to insert Statements between withBefores and withAfters, that take the screen shots on failures.