Thorsten Kamann
Software-Architekt, Coach
              25.05.2009
Webtest?   Tools   Setup & Run
Pitfalls



Automatic Tests
Only manual Tests


Click-Through Testing


Different Browser?


Only new/changed pages
will be tested
Execute Test „anywhere and
anytime“


Repeatable Tests


Avoid the factor „Forgotten“


Old Feature are always tested


No...
Usable for direct testing of Web-UIs


Selenium RemoteControl starts the
commands direct in the browser

No Java-Implement...
Dynamic language for the
Java-Platform

Seamless Integration with
jUnit and TestNG


Powerful Syntax


Easy Learning


Too...
Testframework for
Integrationstesting

Annotation-based
Configuration


Parameterized Tests


Datasource-Support for
creat...
Buildtool


Supports automatically
testing


Integration of Testframeworks


Deklarative


Toolsupport(Eclipse,
Netbeans, ...
Architecture

Usecases

Projectsetup

Execution of Tests

Extensions
Tomcat
       petclinic.war
HSQL
 DB




        Selenium
Run Tests
                            Start
                            Selenium
                   Deploy
               ...
Usecase-driven Tests


Definition of every User-Action


Definition of Inputdata


Definition of Return Values


Recording...
m2Eclipse

GroovyIDE

 TestNG
Java-Project

Maven DM

  Groovy
DM:
Groovy

 DM:
TestNG
Groovy
<dependency>
        <groupId>org.codehaus.groovy</groupId>
        <artifactId>groovy-all</artifactId>
        <ve...
testsuite.xml


Grouping of Tests

• Packages
• Groups
• Include/Excludes

Definition of Parameter
Parameter


<suite name=„webtest-reloadedquot;>
 <test name=„firefox-testsquot; annotations=quot;JDKquot;>
  <parameter na...
Export of Testcases


PHP, C#, Java


JavaScript for Export
Language

Any Target Language is
supported
function assertTrue(expression) {
return
  quot;AssertJUnit.assertTrue(quot; + expression.toString() + quot;)quot;;
}

fun...
public class NewTest {
          Selenium selenium
          String baseUrl = quot;ENTER_BASEURL_HEREquot;

       @Before...
Maven Surefire-Plugin

• Deactivate Lifecycle test
• Activate Lifecycle integration-test
• Integrate TestNG‘s testsuite.xml
Deactivate
                                                            Lifecycle test

<plugin>
 <artifactId>maven-surefir...
pre-integration-test



                         Deploy
 Start Tomcat            Webapp


 post-integration-test



     U...
<<Sourcecode too long…
  please see the sample project>>
pre-integration-test



                            Optional:
  start-server              Prepare
                        ...
Start
                                               Selenium-Server
<plugin>
 <artifactId>selenium-maven-plugin</artifact...
mvn –e surefire-report:report-only




mvn –e clean integration-test
Run As -> TestNG Test




Start Selenium Standalone
Different Browser


  Different OS


   Virtualizing
SpringAOP

Performance of
   Methods
Performance of
    Views

 Stresstests
http://selenium.openqa.org/


http://testng.org/


http://groovy.codehaus.org/


http://maven.apache.org/


http:/www.thor...
Webtests Reloaded - Webtest with Selenium, TestNG, Groovy and Maven
Webtests Reloaded - Webtest with Selenium, TestNG, Groovy and Maven
Webtests Reloaded - Webtest with Selenium, TestNG, Groovy and Maven
Webtests Reloaded - Webtest with Selenium, TestNG, Groovy and Maven
Webtests Reloaded - Webtest with Selenium, TestNG, Groovy and Maven
Webtests Reloaded - Webtest with Selenium, TestNG, Groovy and Maven
Webtests Reloaded - Webtest with Selenium, TestNG, Groovy and Maven
Webtests Reloaded - Webtest with Selenium, TestNG, Groovy and Maven
Webtests Reloaded - Webtest with Selenium, TestNG, Groovy and Maven
Upcoming SlideShare
Loading in...5
×

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

2,947

Published 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 automating the test process.

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
2,947
On Slideshare
0
From Embeds
0
Number of Embeds
12
Actions
Shares
0
Downloads
72
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

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

  1. 1. Thorsten Kamann Software-Architekt, Coach 25.05.2009
  2. 2. Webtest? Tools Setup & Run
  3. 3. Pitfalls Automatic Tests
  4. 4. Only manual Tests Click-Through Testing Different Browser? Only new/changed pages will be tested
  5. 5. Execute Test „anywhere and anytime“ Repeatable Tests Avoid the factor „Forgotten“ Old Feature are always tested Non-breakable Features
  6. 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. 7. Dynamic language for the Java-Platform Seamless Integration with jUnit and TestNG Powerful Syntax Easy Learning Toolsupport (Eclipse, Maven, Ant, …)
  8. 8. Testframework for Integrationstesting Annotation-based Configuration Parameterized Tests Datasource-Support for creation of testdata Toolsupport (Eclipse, Maven, Ant, …)
  9. 9. Buildtool Supports automatically testing Integration of Testframeworks Deklarative Toolsupport(Eclipse, Netbeans, IntelliJ, Konsole)
  10. 10. Architecture Usecases Projectsetup Execution of Tests Extensions
  11. 11. Tomcat petclinic.war HSQL DB Selenium
  12. 12. Run Tests Start Selenium Deploy Webapp Start Tomcat Compile
  13. 13. Usecase-driven Tests Definition of every User-Action Definition of Inputdata Definition of Return Values Recording with Selenium-IDE
  14. 14. m2Eclipse GroovyIDE TestNG
  15. 15. Java-Project Maven DM Groovy
  16. 16. DM: Groovy DM: TestNG
  17. 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. 18. testsuite.xml Grouping of Tests • Packages • Groups • Include/Excludes Definition of Parameter
  19. 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. 20. Export of Testcases PHP, C#, Java JavaScript for Export Language Any Target Language is supported
  21. 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. 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. 23. Maven Surefire-Plugin • Deactivate Lifecycle test • Activate Lifecycle integration-test • Integrate TestNG‘s testsuite.xml
  24. 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. 25. pre-integration-test Deploy Start Tomcat Webapp post-integration-test Undeploy Stop Tomcat Webapp
  26. 26. <<Sourcecode too long… please see the sample project>>
  27. 27. pre-integration-test Optional: start-server Prepare Firexox profile post-integration-test stop-server
  28. 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. 29. mvn –e surefire-report:report-only mvn –e clean integration-test
  30. 30. Run As -> TestNG Test Start Selenium Standalone
  31. 31. Different Browser Different OS Virtualizing
  32. 32. SpringAOP Performance of Methods Performance of Views Stresstests
  33. 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
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×