GoldenFileComparator class Null safety
Compares image pixels against a golden image file.
Instances of this comparator will be used as the backend for matchesGoldenFile.
Instances of this comparator will be invoked by the test framework in the TestWidgetsFlutterBinding.runAsync zone and are thus not subject to the fake async constraints that are normally imposed on widget tests (i.e. the need or the ability to call WidgetTester.pump to advance the microtask queue).
What is Golden File Testing?
The term golden file refers to a master image that is considered the true rendering of a given widget, state, application, or other visual representation you have chosen to capture.
By keeping a master reference of visual aspects of your application, you can prevent unintended changes as you develop by testing against them.
Here, a minor code change has altered the appearance of a widget. A golden file test has compared the image generated at the time of the test to the golden master file that was generated earlier. The test has identified the change, preventing unintended modifications.
|Golden Master Image|
|Test image after modification|
Uint8List imageBytes, Uri golden ) → Future< bool>
Compares the pixels of decoded png
imageBytesagainst the golden file identified by
Uri key, int? version ) → Uri
Returns a new golden file Uri to incorporate any
versionnumber with the
Invocation invocation ) → dynamic
Invoked when a non-existent method or property is accessed. [...]
) → String
Returns a string representation of this object.
Uri golden, Uint8List imageBytes ) → Future< void>
Updates the golden file identified by