UIRegression
Dependency :
compile ":uiregression:0.1"
Summary
Installation
grails install-plugin uiregression
Description
The UIRegression plugin extends the SeleniumRC plugin and adds a "UIRegressionTestCase" resembles a regular SeleniumUnitTestCase, but adds the method "navigateToAndAssertScreenShot".
This method expects a string parameter which is used for naming of this particular comparison test.
It can be any name you want as long as it is unique. Typically it can be the same as the method name, unless you want to assert more
than one screenshot. The second parameter is a closure where you can specify selenium commands to navigate to the page where you want
to assert a screenshot.example:(This switch can also be used to replace reference images in the future.)Once a reference image is generated you can run test-app as normal, and when the rendering changes, the test will fail.
To configure where reference and result images will be stored
To configure the connection to the selenium server
To configure where to connect to your applicationYou can override these in the Config.groovy file under /conf
ui-regression test type to the functional test phase.The plugin uses selenium to capture a screenshot of a page and compare it with reference image.
Which makes refactoring CSS a lot safer!Writing Tests
After installing the plugin, you can create "UIRegressionTestCase" classes in the ui-regression directory.An example test:package samples import net.jozefdransfield.uiregression.UIRegressionTestCase class SampleUIRegressionTests extends UIRegressionTestCase { public void testSample() throws Exception { navigateToAndAssertScreenShot("testSample") { selenium.open("/") } } }
Running
The first time you run "grails test-app", the ui regression test phase will fail, because you have not established a reference image.When you are ready to create reference screen shots you need to rungrails -Duiregression.regenerate=true <regular test app>grails -Duiregression.regenerate=true test-app -functional // pre Grails 1.2 grails -Duiregression.regenerate=true test-app functional:ui-regression // Grails 1.2 +
Configuration
The plugin has the following defaults:config.uiregression.browserstring = '*firefox' config.uiregression.reference.path = 'test/ui-regression/reference/' config.uiregression.result.path = 'test/reports/ui-regression/'
config.uiregression.selenium.host = 'localhost' config.uiregression.selenium.port = 4444
config.uiregression.protocol = 'http' config.uiregression.hostname = 'localhost' config.uiregression.port = 8080