Webtests Reloaded - Webtest with Selenium, TestNG, Groovy and Maven

Uploaded on

The most difficult part to test is the WebUI. This part of an application only manually tested. With Selenium you are able to test WebUIs on a simple way. In this article we shows you how to …

The most difficult part to test is the WebUI. This part of an application only manually tested. With Selenium you are able to test WebUIs on a simple way. In this article we shows you how to automating the test process.

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads


Total Views
On Slideshare
From Embeds
Number of Embeds



Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

    No notes for slide


  • 1. Thorsten Kamann Software-Architekt, Coach 25.05.2009
  • 2. Webtest? Tools Setup & Run
  • 3. Pitfalls Automatic Tests
  • 4. Only manual Tests Click-Through Testing Different Browser? Only new/changed pages will be tested
  • 5. Execute Test „anywhere and anytime“ Repeatable Tests Avoid the factor „Forgotten“ Old Feature are always tested Non-breakable Features
  • 6. Usable for direct testing of Web-UIs Selenium RemoteControl starts the commands direct in the browser No Java-Implementation of a Browser-Engine Create tests with the Selenium-IDE Export the Testskripts with JavaScript in any target language
  • 7. Dynamic language for the Java-Platform Seamless Integration with jUnit and TestNG Powerful Syntax Easy Learning Toolsupport (Eclipse, Maven, Ant, …)
  • 8. Testframework for Integrationstesting Annotation-based Configuration Parameterized Tests Datasource-Support for creation of testdata Toolsupport (Eclipse, Maven, Ant, …)
  • 9. Buildtool Supports automatically testing Integration of Testframeworks Deklarative Toolsupport(Eclipse, Netbeans, IntelliJ, Konsole)
  • 10. Architecture Usecases Projectsetup Execution of Tests Extensions
  • 11. Tomcat petclinic.war HSQL DB Selenium
  • 12. Run Tests Start Selenium Deploy Webapp Start Tomcat Compile
  • 13. Usecase-driven Tests Definition of every User-Action Definition of Inputdata Definition of Return Values Recording with Selenium-IDE
  • 14. m2Eclipse GroovyIDE TestNG
  • 15. Java-Project Maven DM Groovy
  • 16. DM: Groovy DM: TestNG
  • 17. Groovy <dependency> <groupId>org.codehaus.groovy</groupId> <artifactId>groovy-all</artifactId> <version>1.5.6</version> </dependency> <dependency> <groupId>org.testng</groupId> <artifactId>testng</artifactId> <version>5.5</version> <classifier>jdk15</classifier> <optional>true</optional> <scope>test</scope> </dependency> TestNG with JDK5 Annotation-Support
  • 18. testsuite.xml Grouping of Tests • Packages • Groups • Include/Excludes Definition of Parameter
  • 19. Parameter <suite name=„webtest-reloadedquot;> <test name=„firefox-testsquot; annotations=quot;JDKquot;> <parameter name=quot;browserquot; value=quot;firefoxquot;/> <groups> <run> <include name=quot;it-testquot;></include> </run> </groups> Groups <packages> <package name=quot;selenium.groovy.testngquot;/> </packages> </test> </suite> Packages
  • 20. Export of Testcases PHP, C#, Java JavaScript for Export Language Any Target Language is supported
  • 21. function assertTrue(expression) { return quot;AssertJUnit.assertTrue(quot; + expression.toString() + quot;)quot;; } function assignToVariable(type, variable, expression) { return type + quot; quot; + variable + (expression)? quot; = quot; + expression.toString(): quot;quot;; }
  • 22. public class NewTest { Selenium selenium String baseUrl = quot;ENTER_BASEURL_HEREquot; @BeforeClass(groups=[quot;it-testquot;]) public void beforeClass(){…} @BeforeMethod(groups=[quot;it-testquot;]) public void startSelenium(){…} @AfterMethod(groups=[quot;it-testquot;]) public void stopSelenium(){…} @Test(groups=[quot;it-testquot;]) public void executeIntegrationTest { … } }
  • 23. Maven Surefire-Plugin • Deactivate Lifecycle test • Activate Lifecycle integration-test • Integrate TestNG‘s testsuite.xml
  • 24. Deactivate Lifecycle test <plugin> <artifactId>maven-surefire-plugin</artifactId> <configuration> <skip>true</skip> </configuration> Activate <executions> Lifecycle integration-test <execution> <phase>integration-test</phase> <configuration> <skip>false</skip> <suiteXmlFiles> <suiteXmlFile>src/test/config/it-suite.xm</suiteXmlFile> </suiteXmlFiles> </configuration> </execution> Integrate </executions> testsuite </plugin>
  • 25. pre-integration-test Deploy Start Tomcat Webapp post-integration-test Undeploy Stop Tomcat Webapp
  • 26. <<Sourcecode too long… please see the sample project>>
  • 27. pre-integration-test Optional: start-server Prepare Firexox profile post-integration-test stop-server
  • 28. Start Selenium-Server <plugin> <artifactId>selenium-maven-plugin</artifactId> <executions> <execution> <phase>pre-integration-test</phase> <goals> <goal>start-server</goal> </goals> <configuration> <background>true</background> <firefoxProfileTemplate> Prepared Firefox … Profile </firefoxProfileTemplate> </configuration> </execution> </executions> </plugin>
  • 29. mvn –e surefire-report:report-only mvn –e clean integration-test
  • 30. Run As -> TestNG Test Start Selenium Standalone
  • 31. Different Browser Different OS Virtualizing
  • 32. SpringAOP Performance of Methods Performance of Views Stresstests
  • 33. http://selenium.openqa.org/ http://testng.org/ http://groovy.codehaus.org/ http://maven.apache.org/ http:/www.thorsten- kamann.de/weblog/publications/webtests- reloaded-webtests-mit-selenium-testng- groovy-und-maven