Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: FEST-Assert 1.1
-
Component/s: Assert
-
Labels:None
-
Environment:JDK versions: jdk1.6.0_12 (32 bits on XP, 64 bits on Vista)
-
Testcase included:yes
-
Number of attachments :
Description
From Jean-Francois:
Now I am still stuck with my problems comparing screenshots between Windows XP and Vista. This occurs only with Java6 (I have solved the problem with Java5 now).
To make sure the screenshots are comparable between both OS, first of all, I have removed Java6 native font rendering (I have passed "-Dawt.useSystemAAFontSettings=false" to my tests).
Now I get screenshots that really look the same under XP and Vista (see attachment for the simplest case), although the bytestream is different (I am not sure why because both screenshots were taken by FEST).
I have used an image comparison software (http://www.bolidesoft.com/imagecomparer.html free evaluation) to compare these files and it tells me they are 100% identical! So I deduced there may be a problem inside FEST ImageAssert.
Here is the relevant code I use in my tests for checking the screenshots:
BufferedImage screenshot = _screenshot.takeScreenshotOf(_frame.panel("TOP").component()); _screenshot.saveImage(screenshot, snapshot); // Compare with previously recorded snapshots Assertions.assertThat(screenshot).as(expected).isEqualTo(ImageAssert.read(expected));
where _screenshot is a ScreenshotTaker instance, snapshot is the path to which I save the new snapshot, expected is the path where the "reference" snapshot is stored.
the exception I get is:
java.lang.AssertionError: [src/test/resources/screenshots/java6/basics/Basics9RealWorldExample3.png] images do not have the same color(s) at org.fest.assertions.Fail.fail(Fail.java:85) at org.fest.assertions.GenericAssert.fail(GenericAssert.java:211) at org.fest.assertions.ImageAssert.isEqualTo(ImageAssert.java:166) at net.java.dev.designgridlayout.AbstractGuiTest.checkSnapshot(AbstractGuiTest.java:167) at net.java.dev.designgridlayout.AbstractGuiTest.checkSnapshot(AbstractGuiTest.java:143) at net.java.dev.designgridlayout.AbstractGuiTest.checkExample(AbstractGuiTest.java:109) at net.java.dev.designgridlayout.basics.BasicFeaturesTest.checkJGoodiesSkeleton(BasicFeaturesTest.java:68) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.testng.internal.MethodHelper.invokeMethod(MethodHelper.java:580) at org.testng.internal.Invoker.invokeMethod(Invoker.java:478) at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:617) at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:885) at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:126) at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:110) at org.testng.TestRunner.runWorkers(TestRunner.java:712) at org.testng.TestRunner.privateRun(TestRunner.java:582) at org.testng.TestRunner.run(TestRunner.java:477) at org.testng.SuiteRunner.runTest(SuiteRunner.java:324) at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:319) at org.testng.SuiteRunner.privateRun(SuiteRunner.java:292) at org.testng.SuiteRunner.run(SuiteRunner.java:198) at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:821) at org.testng.TestNG.runSuitesLocally(TestNG.java:788) at org.testng.TestNG.run(TestNG.java:708) at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:62) at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.execute(TestNGDirectoryTestSuite.java:141) at org.apache.maven.surefire.Surefire.run(Surefire.java:177) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:345) at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1009)
The attachment contains 2 files:
- the "reference" screenshot that was first taken on Vista 64 bits (in expected-VISTA folder)
- the screenshot taken during the tests on Windows XP (in actual-XP folder)
Both JDK versions are the same: jdk1.6.0_12 (32 bits on XP, 64 bits on Vista).
Well I think that's all information I can give you about this problem (but if you need more, please feel free to ask!)
If you could take a look at what can be wrong, that would help me a lot!
Thank you Alex for opening this issue. The exception stack trace I sent you is actually not the one matching the screenshots in the attachment (made a copy/paste mistake from my test log).
The actual stack trace is:
java.lang.AssertionError: [src/test/resources/screenshots/java6/basics/Basics1SimpleGrid.png] images do not have the same color(s)
at org.fest.assertions.Fail.fail(Fail.java:85)
at org.fest.assertions.GenericAssert.fail(GenericAssert.java:211)
at org.fest.assertions.ImageAssert.isEqualTo(ImageAssert.java:166)
at net.java.dev.designgridlayout.AbstractGuiTest.checkSnapshot(AbstractGuiTest.java:167)
at net.java.dev.designgridlayout.AbstractGuiTest.checkSnapshot(AbstractGuiTest.java:143)
at net.java.dev.designgridlayout.AbstractGuiTest.checkExample(AbstractGuiTest.java:109)
at net.java.dev.designgridlayout.basics.BasicFeaturesTest.checkSimpleGrid(BasicFeaturesTest.java:33)
....
It is essentially the same as the original one except that it was run from another test case and the screenshot reference is correct that time.
After a quick look at the source of ImageAssert, I could not find any obvious hint that would explain this behavior.
It might be interesting to run the TC in debug mode and check how the 2 BufferedImages are different (I suspect their ColorModels might differ but there is no certitude).
By the way it might be useful that the ImageAssert.isEqualTo() creates an exception with a more detailed message, in particular which pixel (x,y) was found different, what was the exepected and the actual colors?
I'll see tonight if I can try to check my tests in debug mode (I never run them from eclipse normally, only from maven...)