SlideShare a Scribd company logo
- Selenium - Browser-Based Automated Testing of Web Apps Under Continuous Integration  Presented By Chris Bedford Founder & Lackey at Large Build Lackey Labs Company Overview  Founded  2008 Services Release engineering  &  Build/Test Automation for Java Environments Spring/Hibernate & Groovy/Grails App Development Training:  Spring/Groovy/Grails & Build/Test Automation Technologies Employees  Chris Bedford Mike Jackson
Agenda Different Ways To Test a Grails App Unit, Integration, Functional Selenium Demo of IDE Architecture Alternatives (Canoo WebTest) Automating Testing Using Selenium Maven Demo  Cargo  Viewing Test Results Lab 1 – maven project Ant Continuous Integration With Hudson How to write functional tests with Selenium KEY TAKE-AWAYS How to set up Selenium Testing  On Grails Apps  In Continuous  Integration Building  With Ant Building with maven Continuous  Integration With Hudson
Unit Unit Tests are created and run developer and run using framework like Junit or TestNG test class or package functionality in isolation heavy use of mocks and stubs  tests should execute quickly and be run often to catch problems early on Integration If you are dependent on someone else’s stuff, the test includes your stuff and theirs Verifies that two or more components work together,  usually directly, and not with mocks To simplify test set-up components typically execute same JVM process Functional Testing Run application in container  Exercise functionality via a client side agent that executes Javascript. Agent could be either: your actual target browser (Firefox, IE, etc.)  [Selenium's approach] a Javascript engine embedded into test framework  [Canoo Webtest's approach] Different Ways To Test a Java Web App Real http requests Separate client Mock http requests Client requests from same process Package or class level scope increasingly  coarse  grained  components  under  test
Manual Steps Involved In Running Selenium Before running Selenium Functional Tests we need to  Compile classes Run unit and integration tests  bail on functional tests if we catch problems with lighter weight tests Package .war file Install and start the container in which we want to run the .war  Deploy the .war to the container  unless your running Jetty, which runs embedded in your app Launch target browser Launch Selenium on desired test suite
Launching Selenium
Recording New Selenium Tests
Exporting test commands to 3GL (Java, etc.)
Individual tests referenced by the suite are recorded using their paths relative to the suite. For simplicity put your suite and all tests in the same directory (to start) Saving New or Modified Selenium Tests
Selenium Components Selenium IDE Selenese Commands Enable test author to  simulate navigation, clicks Make assertions about expected responses Selenium RC Client side library that enables you to program more sophistication into your tests than the IDE allows  (conditions, looping, error handling) The Selenium Server which launches and kills browsers, interprets and runs the Selenese commands passed from the test program, and acts as an  HTTP proxy ,
Selenium Client Side Library & Server In Action HTTP Selenium-server.jar Source: http://seleniumhq.org/docs/05_selenium_rc.html Reports back  results of test to client HTTP (javascript) (client side java script / Ajax portion of application under Test – originates from  here ) Application  under test (server side)
A Look Same Origin Policy (Which Selenium’s Architecture Circumvents) Same origin policy: Forbids JavaScript code running on a  web page  from interacting with resources which originate from any web site other than the one which served up that  web page
Selenium RC Server Acting As Proxy To Avoid Same Origin Policy Restrictions What happens when a test suite starts ? 1) client/driver establishes  connection w.selenium-RC  2)  Selenium-RC server launches a browser (or reuses an old one) with URL that injects Selenium-Core’s javascript into browser-loaded web page. 3) client-driver passes a Selenese command to the server e.g.: open command 4) Server interprets the command and then triggers the corresponding javascript execution to execute that command within the browser (say open page in app under test)s 5) Request to open the page is routed through proxy server 6) 7) Proxy forwards request to app  server App server returns response
Functional Test Alternatives: Canoo vs Selenium Canoo Web Test built on HtmlUnit pros: excellent test reporting allows you to pin point errors in test very easily. faster to run (no browser spin up overhead) better support for non HTML content (like spread sheets) cons: Weaker IDE (for test recording and playback) develop tests in Ant or Gant only Selenium pros: develop tests in HTML markup or 3 GL's like Java, Ruby, etc. run test in actual browser  vs.embedded Javascript engine used by NO popular browser platform cons: slower to start. see 'pros' listed Canoo RECOMMENDATION:  I’d go with Canoo for testing a REST-ful API
Canoo Web Test Reports Canoo's reports show overall test results and let you drill down into any test
Canoo Web Test Reports (cont.) Click to review a copy of the response HTML page corresponding to the first test step that failed
Gluing together the steps in your build process Before running Functional Tests need to  Compile Run unit and integration tests  bail on functional tests if we catch problems with lighter weight tests Package .war file Install the container in which we want to run the .war  (optional) Deploy the .war to the container (optional – can just do ‘grails run-app’) Launch your target browser Launch Selenium on your desired test suite To automate this process you can use ant maven Groovy/Gant scripts Gradle Our example uses Maven (demo) (tour of pom.xml files that wire together our build steps)
deploy Compile Unit Test  Integration Test Package .war file Download And Install Tomcat
Structure of our demo project mvn install Maven Repository Lives in $HOME/.m2/repostitory or  /Docuemts and Settings/<user>/.m2/repository declares the artifact it produces to be  org.example:demo:1.1 declares a a dependency on org.example:demo:1.1 org.example:demo:1.1
Demo All Tests Pass Some Tests Fail
Maven Basics Convention over configuration Standardizes where things live and what they are named  Lets you know where to look for the things you need…  and what to do when you find them Project Object Model  (pom.xml) specifies the complete ‘recipe for your build’ what artifact type are your producing ? (the name, the version…) what are the dependencies (things you need) to produce that artifact ? What plug-ins activate at what phases in the build life cycle ? Shared Repository for storing artifacts that result from a build Convention for naming artifacts Build Life Cycle each project is typically responsible for producing a distinct artifact (a.k.a. packaging) type  .jar, .war, .ear, etc.  each packaging type has an associated  life cycle (ordered set of build phases) Nested build project (module) structure overall driver for your build project lives at top level of a directory hierarchy sub-modules  underneath  the parent can be either  individual components of your product …or….  key phases in your build
Maven Nested Module Structure, Dependencies and Shared Repo mvn install Maven Repository Lives in $HOME/.m2/repostitory or  /Docuemts and Settings/<user>/.m2/repository declares the artifact it produces to be  org.example:demo:1.1 declares a a dependency on org.example:demo:1.1 org.example:demo:1.1
Maven pom.xml – Nested Module Structure
Maven pom.xml – Dependency Relationships Maven Repository org.example:demo:1.1
Hooking Maven Plug-ins Maven Into the Build Life Cycle  Build Life Cycle Phases validate  generate/process-sources process-sources  generate/process-resources  compile test prepare-package  package pre-integration-test integration-test  post-integration-test  verify  install  deploy pom.xml
Cargo  A set of APIs that assists in installing web containers (such as Tomcat, JBoss) booting and shutting them down deploying web applications (.wars and .ears) Invokable via ant tasks maven plugin Java API <target name=&quot;functional-test&quot; > <cargo containerId=&quot;tomcat6x&quot; action=&quot;start&quot;  …  > <zipurlinstaller installurl=&quot;http://somewhere/tomcat-6.0.zip&quot;/> <configuration type=&quot;standalone&quot; home=&quot;${tomcatdir}&quot;> <deployable type=&quot;war&quot; file=&quot;foo.war&quot;/> </configuration> </cargo> <plugin> ... <artifactId>cargo-maven2-plugin</artifactId> <config> <wait>false</wait> <container> <containerId>tomcat6x</containerId> <zipUrlInstaller> <url>http://somewhere/tomcat-6.0.zip</url> ... Installer installer =  new URL(&quot;http://somewhere/tomcat-6.0.zip&quot;)); installer.iZipURLInstaller(new nstall(); LocalConfiguration configuration =  new DefaultConfigurationFactory().createConfiguration(&quot;tomcat6x&quot;)...) container = new DefaultContainerFactory() .createContainer(&quot;tomcat6x&quot;....); container.setHome(installer.getHome()); WAR deployable = new WAR(&quot;foo.war);  deployable.setContext(&quot;ROOT&quot;); configuration.addDeployable(deployable);
Launching Selenium Via Ant Walk through of ant script that launches Selenium server in separate JVM,  Waits for server ready, then launches Selenium tests,  then waits for shut down
 
 
Continuous Integration Dedicated box runs regular full builds (including tests) of your software Build triggers whenever any developer checks into SCM  Team is notified of any failures
Continuous Integration Benefits Replaces big (and long) integration cycles with small frequent ones. Same benefits as continous compilation in Eclipse Immediate feedback when an error is introduced. Fewer deltas between when it worked and when it broke  => easier resolution of failures Lower ripple through impact when colleagues checks in broken code CI server build fails & team is notified  Other developers know it is not safe to pull from source Mail sent out when build goes back to normal
Workflow After Adopting Continous Integration CI Server: 0- Receive notification of change in SCM repo 1- Check out latest sources  2- Build from scratch 3  Build passes? yes:  publish, e.g., deploy .war to QA server  no:  send out email, flash red lights ... Developer: 0- Check CI server for current build status broken ?  don't update !  ... otherwise.. 1- check out from SCM 2- code new feature  3- run automated build on your box  4- Tests pass ? no? go back to 2 ! 5- Commit changes  SCM Repo broken ! Build ok?
Continuous Integration With Hudson  Hudson orchestrates the execution of repeatable jobs periodic builds (e.g., nightly)  builds that are triggered by some event (like checkin to source control) Keeps History of Past Builds (Trend Reports) Notifies When Builds Fail Written in Java and runs from a .jar (no install required)  Integrates with wide range of SCM systems (SVN, P4, etc.) Supports ant, maven, shell script based builds
Small Sample of Available Hudson Plug-ins Project Metrics Code Coverage (clover, cobertura, emma) Checkstyle  Frameworks Grails  (invoke grails tasks as build steps) Gradle  Build Wrappers Locks and Latches  - allows orchestration of  multiple jobs Build Time Out
Resources Selenium Mailing List  http://old.nabble.com/Selenium-f14083.html Selenium Web Site http://seleniumhq.org/ Ant and Maven CI Tips & Tricks http://wiki.openqa.org/display/SRC/Selenium-RC+and+Continuous+Integration
Thank You  !
Content Licensing Terms for This Work You may present, distribute, copy, or incorporate into your own work, any and all portions of this presentation as long as such copies, or derivative works are made available without charge. If you would like to redistribute this work on any type of fee-for-use or subscription basis, or if you wish incorporate any or all portions of this work into content which you charge for, please contact info <at> buildlackey.com to discuss licensing terms.

More Related Content

PDF
Expert selenium with core java
PPTX
Basic Selenium Training
PPT
Jenkins - Continuous Integration after Hudson, CruiseControl, and home built
PPTX
BDD using Cucumber JVM
PDF
Foundation selenium java
PPTX
Automated Testing using JavaScript
PPT
Selenium Java for Beginners by Sujit Pathak
PPTX
Expert selenium with core java
Basic Selenium Training
Jenkins - Continuous Integration after Hudson, CruiseControl, and home built
BDD using Cucumber JVM
Foundation selenium java
Automated Testing using JavaScript
Selenium Java for Beginners by Sujit Pathak

What's hot (20)

PPTX
CollabSphere 2018 - Java in Domino After XPages
PPTX
CI / CD w/ Codeception
PDF
How To Use Selenium Successfully (Java Edition)
PPTX
Testing Java EE apps with Arquillian
PDF
Testing with Codeception
PDF
Automated Web Testing using JavaScript
KEY
Testing with Jenkins, Selenium and Continuous Deployment
PDF
Testing Code.org's Interactive CS Curriculum
PDF
Selenium webdriver interview questions and answers
PPTX
Test automation with php codeception
PPTX
Selenium Training in Chennai
PDF
Testing with Codeception (Webelement #30)
PDF
Front-End Testing: Demystified
PDF
Introduction to Protractor
PPT
Demystifying Maven
PPT
Selenium2 and Jenkins: Almost pain-free UI Testing
PDF
Efficient JavaScript Unit Testing, May 2012
PPTX
Automation Tools Overview
PDF
Apache Maven In 10 Slides
PPT
Maven Overview
CollabSphere 2018 - Java in Domino After XPages
CI / CD w/ Codeception
How To Use Selenium Successfully (Java Edition)
Testing Java EE apps with Arquillian
Testing with Codeception
Automated Web Testing using JavaScript
Testing with Jenkins, Selenium and Continuous Deployment
Testing Code.org's Interactive CS Curriculum
Selenium webdriver interview questions and answers
Test automation with php codeception
Selenium Training in Chennai
Testing with Codeception (Webelement #30)
Front-End Testing: Demystified
Introduction to Protractor
Demystifying Maven
Selenium2 and Jenkins: Almost pain-free UI Testing
Efficient JavaScript Unit Testing, May 2012
Automation Tools Overview
Apache Maven In 10 Slides
Maven Overview
Ad

Similar to Testing Java Web Apps With Selenium (20)

PPT
Selenium-Browser-Based-Automated-Testing-for-Grails-Apps
KEY
Enterprise Build And Test In The Cloud
KEY
Enterprise Build And Test In The Cloud
PDF
Webtests Reloaded - Webtest with Selenium, TestNG, Groovy and Maven
DOC
PPTX
Selenium Testing
PPTX
Selenium – testing tool jack
PDF
full-stack-webapp-testing-with-selenium-and-rails.pdf
PDF
Selenium
ODP
WebTest - Efficient Functional Web Testing with HtmlUnit and Beyond
PPTX
ZIP
Browser-Based testing using Selenium
PPT
Selenium Introduction
KEY
Selenium at STPCon - Dallas 2011
PPT
Selenium
PPT
Selenium and The Grinder
PPT
Testing Web Apps With Scripting Language - Mark Rees, Century Software
PPT
BCS Selenium Workshop
PPTX
4&5.pptx SOFTWARE TESTING UNIT-4 AND UNIT-5
PPTX
Automated testing with Drupal
Selenium-Browser-Based-Automated-Testing-for-Grails-Apps
Enterprise Build And Test In The Cloud
Enterprise Build And Test In The Cloud
Webtests Reloaded - Webtest with Selenium, TestNG, Groovy and Maven
Selenium Testing
Selenium – testing tool jack
full-stack-webapp-testing-with-selenium-and-rails.pdf
Selenium
WebTest - Efficient Functional Web Testing with HtmlUnit and Beyond
Browser-Based testing using Selenium
Selenium Introduction
Selenium at STPCon - Dallas 2011
Selenium
Selenium and The Grinder
Testing Web Apps With Scripting Language - Mark Rees, Century Software
BCS Selenium Workshop
4&5.pptx SOFTWARE TESTING UNIT-4 AND UNIT-5
Automated testing with Drupal
Ad

More from Marakana Inc. (20)

PDF
Android Services Black Magic by Aleksandar Gargenta
PDF
JRuby at Square
PDF
Behavior Driven Development
PDF
Martin Odersky: What's next for Scala
PPT
Why Java Needs Hierarchical Data
PDF
Deep Dive Into Android Security
PDF
Securing Android
PDF
Pictures from "Learn about RenderScript" meetup at SF Android User Group
PDF
Android UI Tips, Tricks and Techniques
PDF
2010 07-18.wa.rails tdd-6
PDF
Efficient Rails Test-Driven Development - Week 6
PDF
Graphicsand animations devoxx2010 (1)
PDF
What's this jQuery? Where it came from, and how it will drive innovation
PDF
jQuery State of the Union - Yehuda Katz
PDF
Pics from: "James Gosling on Apple, Apache, Google, Oracle and the Future of ...
PDF
Efficient Rails Test Driven Development (class 4) by Wolfram Arnold
PDF
Efficient Rails Test Driven Development (class 3) by Wolfram Arnold
PDF
Learn about JRuby Internals from one of the JRuby Lead Developers, Thomas Enebo
PDF
Replacing Java Incrementally
PDF
Learn to Build like you Code with Apache Buildr
Android Services Black Magic by Aleksandar Gargenta
JRuby at Square
Behavior Driven Development
Martin Odersky: What's next for Scala
Why Java Needs Hierarchical Data
Deep Dive Into Android Security
Securing Android
Pictures from "Learn about RenderScript" meetup at SF Android User Group
Android UI Tips, Tricks and Techniques
2010 07-18.wa.rails tdd-6
Efficient Rails Test-Driven Development - Week 6
Graphicsand animations devoxx2010 (1)
What's this jQuery? Where it came from, and how it will drive innovation
jQuery State of the Union - Yehuda Katz
Pics from: "James Gosling on Apple, Apache, Google, Oracle and the Future of ...
Efficient Rails Test Driven Development (class 4) by Wolfram Arnold
Efficient Rails Test Driven Development (class 3) by Wolfram Arnold
Learn about JRuby Internals from one of the JRuby Lead Developers, Thomas Enebo
Replacing Java Incrementally
Learn to Build like you Code with Apache Buildr

Recently uploaded (20)

PPTX
PPH.pptx obstetrics and gynecology in nursing
PPTX
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PDF
RMMM.pdf make it easy to upload and study
PPTX
master seminar digital applications in india
PDF
01-Introduction-to-Information-Management.pdf
PPTX
Cell Types and Its function , kingdom of life
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PDF
Insiders guide to clinical Medicine.pdf
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PDF
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
PDF
Complications of Minimal Access Surgery at WLH
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
Business Ethics Teaching Materials for college
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
Classroom Observation Tools for Teachers
PDF
Mark Klimek Lecture Notes_240423 revision books _173037.pdf
PDF
Microbial disease of the cardiovascular and lymphatic systems
PPH.pptx obstetrics and gynecology in nursing
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
O5-L3 Freight Transport Ops (International) V1.pdf
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
RMMM.pdf make it easy to upload and study
master seminar digital applications in india
01-Introduction-to-Information-Management.pdf
Cell Types and Its function , kingdom of life
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
2.FourierTransform-ShortQuestionswithAnswers.pdf
Insiders guide to clinical Medicine.pdf
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
Complications of Minimal Access Surgery at WLH
Microbial diseases, their pathogenesis and prophylaxis
Business Ethics Teaching Materials for college
O7-L3 Supply Chain Operations - ICLT Program
Classroom Observation Tools for Teachers
Mark Klimek Lecture Notes_240423 revision books _173037.pdf
Microbial disease of the cardiovascular and lymphatic systems

Testing Java Web Apps With Selenium

  • 1. - Selenium - Browser-Based Automated Testing of Web Apps Under Continuous Integration Presented By Chris Bedford Founder & Lackey at Large Build Lackey Labs Company Overview Founded 2008 Services Release engineering & Build/Test Automation for Java Environments Spring/Hibernate & Groovy/Grails App Development Training: Spring/Groovy/Grails & Build/Test Automation Technologies Employees Chris Bedford Mike Jackson
  • 2. Agenda Different Ways To Test a Grails App Unit, Integration, Functional Selenium Demo of IDE Architecture Alternatives (Canoo WebTest) Automating Testing Using Selenium Maven Demo Cargo Viewing Test Results Lab 1 – maven project Ant Continuous Integration With Hudson How to write functional tests with Selenium KEY TAKE-AWAYS How to set up Selenium Testing On Grails Apps In Continuous Integration Building With Ant Building with maven Continuous Integration With Hudson
  • 3. Unit Unit Tests are created and run developer and run using framework like Junit or TestNG test class or package functionality in isolation heavy use of mocks and stubs tests should execute quickly and be run often to catch problems early on Integration If you are dependent on someone else’s stuff, the test includes your stuff and theirs Verifies that two or more components work together, usually directly, and not with mocks To simplify test set-up components typically execute same JVM process Functional Testing Run application in container Exercise functionality via a client side agent that executes Javascript. Agent could be either: your actual target browser (Firefox, IE, etc.) [Selenium's approach] a Javascript engine embedded into test framework [Canoo Webtest's approach] Different Ways To Test a Java Web App Real http requests Separate client Mock http requests Client requests from same process Package or class level scope increasingly coarse grained components under test
  • 4. Manual Steps Involved In Running Selenium Before running Selenium Functional Tests we need to Compile classes Run unit and integration tests bail on functional tests if we catch problems with lighter weight tests Package .war file Install and start the container in which we want to run the .war Deploy the .war to the container unless your running Jetty, which runs embedded in your app Launch target browser Launch Selenium on desired test suite
  • 7. Exporting test commands to 3GL (Java, etc.)
  • 8. Individual tests referenced by the suite are recorded using their paths relative to the suite. For simplicity put your suite and all tests in the same directory (to start) Saving New or Modified Selenium Tests
  • 9. Selenium Components Selenium IDE Selenese Commands Enable test author to simulate navigation, clicks Make assertions about expected responses Selenium RC Client side library that enables you to program more sophistication into your tests than the IDE allows (conditions, looping, error handling) The Selenium Server which launches and kills browsers, interprets and runs the Selenese commands passed from the test program, and acts as an HTTP proxy ,
  • 10. Selenium Client Side Library & Server In Action HTTP Selenium-server.jar Source: http://seleniumhq.org/docs/05_selenium_rc.html Reports back results of test to client HTTP (javascript) (client side java script / Ajax portion of application under Test – originates from here ) Application under test (server side)
  • 11. A Look Same Origin Policy (Which Selenium’s Architecture Circumvents) Same origin policy: Forbids JavaScript code running on a web page from interacting with resources which originate from any web site other than the one which served up that web page
  • 12. Selenium RC Server Acting As Proxy To Avoid Same Origin Policy Restrictions What happens when a test suite starts ? 1) client/driver establishes connection w.selenium-RC 2) Selenium-RC server launches a browser (or reuses an old one) with URL that injects Selenium-Core’s javascript into browser-loaded web page. 3) client-driver passes a Selenese command to the server e.g.: open command 4) Server interprets the command and then triggers the corresponding javascript execution to execute that command within the browser (say open page in app under test)s 5) Request to open the page is routed through proxy server 6) 7) Proxy forwards request to app server App server returns response
  • 13. Functional Test Alternatives: Canoo vs Selenium Canoo Web Test built on HtmlUnit pros: excellent test reporting allows you to pin point errors in test very easily. faster to run (no browser spin up overhead) better support for non HTML content (like spread sheets) cons: Weaker IDE (for test recording and playback) develop tests in Ant or Gant only Selenium pros: develop tests in HTML markup or 3 GL's like Java, Ruby, etc. run test in actual browser vs.embedded Javascript engine used by NO popular browser platform cons: slower to start. see 'pros' listed Canoo RECOMMENDATION: I’d go with Canoo for testing a REST-ful API
  • 14. Canoo Web Test Reports Canoo's reports show overall test results and let you drill down into any test
  • 15. Canoo Web Test Reports (cont.) Click to review a copy of the response HTML page corresponding to the first test step that failed
  • 16. Gluing together the steps in your build process Before running Functional Tests need to Compile Run unit and integration tests bail on functional tests if we catch problems with lighter weight tests Package .war file Install the container in which we want to run the .war (optional) Deploy the .war to the container (optional – can just do ‘grails run-app’) Launch your target browser Launch Selenium on your desired test suite To automate this process you can use ant maven Groovy/Gant scripts Gradle Our example uses Maven (demo) (tour of pom.xml files that wire together our build steps)
  • 17. deploy Compile Unit Test Integration Test Package .war file Download And Install Tomcat
  • 18. Structure of our demo project mvn install Maven Repository Lives in $HOME/.m2/repostitory or /Docuemts and Settings/<user>/.m2/repository declares the artifact it produces to be org.example:demo:1.1 declares a a dependency on org.example:demo:1.1 org.example:demo:1.1
  • 19. Demo All Tests Pass Some Tests Fail
  • 20. Maven Basics Convention over configuration Standardizes where things live and what they are named Lets you know where to look for the things you need… and what to do when you find them Project Object Model (pom.xml) specifies the complete ‘recipe for your build’ what artifact type are your producing ? (the name, the version…) what are the dependencies (things you need) to produce that artifact ? What plug-ins activate at what phases in the build life cycle ? Shared Repository for storing artifacts that result from a build Convention for naming artifacts Build Life Cycle each project is typically responsible for producing a distinct artifact (a.k.a. packaging) type .jar, .war, .ear, etc. each packaging type has an associated life cycle (ordered set of build phases) Nested build project (module) structure overall driver for your build project lives at top level of a directory hierarchy sub-modules underneath the parent can be either individual components of your product …or…. key phases in your build
  • 21. Maven Nested Module Structure, Dependencies and Shared Repo mvn install Maven Repository Lives in $HOME/.m2/repostitory or /Docuemts and Settings/<user>/.m2/repository declares the artifact it produces to be org.example:demo:1.1 declares a a dependency on org.example:demo:1.1 org.example:demo:1.1
  • 22. Maven pom.xml – Nested Module Structure
  • 23. Maven pom.xml – Dependency Relationships Maven Repository org.example:demo:1.1
  • 24. Hooking Maven Plug-ins Maven Into the Build Life Cycle Build Life Cycle Phases validate generate/process-sources process-sources generate/process-resources compile test prepare-package package pre-integration-test integration-test post-integration-test verify install deploy pom.xml
  • 25. Cargo A set of APIs that assists in installing web containers (such as Tomcat, JBoss) booting and shutting them down deploying web applications (.wars and .ears) Invokable via ant tasks maven plugin Java API <target name=&quot;functional-test&quot; > <cargo containerId=&quot;tomcat6x&quot; action=&quot;start&quot; … > <zipurlinstaller installurl=&quot;http://somewhere/tomcat-6.0.zip&quot;/> <configuration type=&quot;standalone&quot; home=&quot;${tomcatdir}&quot;> <deployable type=&quot;war&quot; file=&quot;foo.war&quot;/> </configuration> </cargo> <plugin> ... <artifactId>cargo-maven2-plugin</artifactId> <config> <wait>false</wait> <container> <containerId>tomcat6x</containerId> <zipUrlInstaller> <url>http://somewhere/tomcat-6.0.zip</url> ... Installer installer = new URL(&quot;http://somewhere/tomcat-6.0.zip&quot;)); installer.iZipURLInstaller(new nstall(); LocalConfiguration configuration = new DefaultConfigurationFactory().createConfiguration(&quot;tomcat6x&quot;)...) container = new DefaultContainerFactory() .createContainer(&quot;tomcat6x&quot;....); container.setHome(installer.getHome()); WAR deployable = new WAR(&quot;foo.war); deployable.setContext(&quot;ROOT&quot;); configuration.addDeployable(deployable);
  • 26. Launching Selenium Via Ant Walk through of ant script that launches Selenium server in separate JVM, Waits for server ready, then launches Selenium tests, then waits for shut down
  • 27.  
  • 28.  
  • 29. Continuous Integration Dedicated box runs regular full builds (including tests) of your software Build triggers whenever any developer checks into SCM Team is notified of any failures
  • 30. Continuous Integration Benefits Replaces big (and long) integration cycles with small frequent ones. Same benefits as continous compilation in Eclipse Immediate feedback when an error is introduced. Fewer deltas between when it worked and when it broke => easier resolution of failures Lower ripple through impact when colleagues checks in broken code CI server build fails & team is notified Other developers know it is not safe to pull from source Mail sent out when build goes back to normal
  • 31. Workflow After Adopting Continous Integration CI Server: 0- Receive notification of change in SCM repo 1- Check out latest sources 2- Build from scratch 3 Build passes? yes: publish, e.g., deploy .war to QA server no: send out email, flash red lights ... Developer: 0- Check CI server for current build status broken ? don't update ! ... otherwise.. 1- check out from SCM 2- code new feature 3- run automated build on your box 4- Tests pass ? no? go back to 2 ! 5- Commit changes SCM Repo broken ! Build ok?
  • 32. Continuous Integration With Hudson Hudson orchestrates the execution of repeatable jobs periodic builds (e.g., nightly) builds that are triggered by some event (like checkin to source control) Keeps History of Past Builds (Trend Reports) Notifies When Builds Fail Written in Java and runs from a .jar (no install required) Integrates with wide range of SCM systems (SVN, P4, etc.) Supports ant, maven, shell script based builds
  • 33. Small Sample of Available Hudson Plug-ins Project Metrics Code Coverage (clover, cobertura, emma) Checkstyle Frameworks Grails (invoke grails tasks as build steps) Gradle Build Wrappers Locks and Latches - allows orchestration of multiple jobs Build Time Out
  • 34. Resources Selenium Mailing List http://old.nabble.com/Selenium-f14083.html Selenium Web Site http://seleniumhq.org/ Ant and Maven CI Tips & Tricks http://wiki.openqa.org/display/SRC/Selenium-RC+and+Continuous+Integration
  • 36. Content Licensing Terms for This Work You may present, distribute, copy, or incorporate into your own work, any and all portions of this presentation as long as such copies, or derivative works are made available without charge. If you would like to redistribute this work on any type of fee-for-use or subscription basis, or if you wish incorporate any or all portions of this work into content which you charge for, please contact info <at> buildlackey.com to discuss licensing terms.