Roo, Selenium WebDriver,Failsafe and JUnit - Smores, anyone?
Sunday, January 8, 2012 at 3:42PM S'Mores are about the perfect mix of sugar, sugar and chocolate. So, the programming equivalent would be getting your Selenium tests separated from your unit tests, and running in an API that just needs a web server, not a separate Selenium server, right?
(Ok, I'm stretching it).
A WebDriver test
First, here is an integration test, ITCourseSelenium.java that uses the Selenium WebDriver API. Look how simple the code is:
Next up, we have the Maven configuration for the various plugins to install Selenium (forget the current Selenium Roo add-on for this, it only sets up HTML tests and doesn't include the Java API, plus doesn't install WebDriver and needs to run on a port, which is tricky):
Selenium Configuration
Add these elements to your pom.xml file to set up the configuration:
These fragments configure a jetty web server, which starts up before integration testing. They also configure the maven-failsafe-plugin, which is attached to the integration-test and verify Maven lifecycle phases.
Running the tests
To run your tests, just issue the mvn verify command. All tests starting or ending with IT will run after the web application starts, and will be recorded as test results in target/failsafe-reports.
Enjoy.
Ken
SpringSource Roo in
Spring Roo,
Tips 


