- I want plain HTML TestCases, created with Selenium-IDE. So that someone with little Programming skills can still create them.
- I want these GUI Tests to be run automatically in my Build process, so my CI-Tool can notify me on errors.
- I also want all TestCases under Versioncontrol in my Projects Repository since the Tests grow with the Source.
- I want the most little effort with the highest outcome. So i dont want to export JUnit Tests out of my HTML TestCases since it would be kind of a Duplication - and i want to stick to the DRY Principle.
SolutionFirst of all i create a Folder in my Project for the Selenium-Tests.
Setup WebServerSo i have my TestSuite in place. But how do i run them? Most importantly, it should run within the Maven Build Process, so it will also run on Jenkins-CI or whatever. As we are testing against a real running WebApp this is an End-to-End-Test per definition. In Maven we have the opportunity to run such Tests within the integration-test Phase. If you want to learn more about the Maven Build Life-cycle and its phases check out this. So we need some kind of WebServer to run our WebApp, otherwise the tests wont work. The WebServer should be started before the integration-test phase, and be stopped afterwards. We could Use Tomcat7 or Jetty for example. In this example i will use the tomcat7-maven-plugin. I configure my pom.xml to start Tomcat7 pre-integration-test.
If you are running multiple Projects on a CI-Server you might consider using a different Port-Number for each Project.
Finally: Run the TestsLast but not least we need to run the tests. Luckily there is this selenium-maven-plugin available that does the job.
Now, whenever we execute mvn clean verify or even mvn clean install in console, the Tests are run and reports are stored within the target directory. This will also be done by your CI-Tool.
ConclusionWe do have a complete and clean Setup.
- We have a place to store our Tests,
- They are within the Sourcecode and Version control
- They can be run automatically by CI-Tools
- Even Non-developers can add new TestCases
I hope you enjoyed this Guide. Greetings.