San Francisco Java User Group presents Chris Bedford who talks about:
- How to write functional tests with Selenium (including explaining its IDE, architecture, RC, and alternatives like Canoo WebTest)
- How to set up Selenium testing for web apps in continuous integration using Maven, Ant, Cargo, etc.
- How to use Hudson for build server (brief overview)
January 12, 2010 in San Francisco, CA
http://www.sfjava.org/calendar/11982857/
Hosted by SUPINFO International University
Sponsored by TEKsystems, Guidewire Software, Sun, O'Reilly, JetBrains, and Marakana.
Video by Max Walker
Organized by Marakana
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
Testing Java Web Apps With Selenium
1.
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
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.
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.
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.
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
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
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.
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
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.