SlideShare a Scribd company logo
- Selenium - Browser-Based Automated Testing of Grails Apps 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 Cargo  Viewing Test Results Lab 1 – maven project Alternative Automation Strategies grails-selenium-rc plugin Lab 2 – using selenium-rc plugin How to write functional tests with Selenium KEY TAKE-AWAYS How to set up Selenium Testing  On Grails Apps  In Continuous  Integration The fast way, using the grails-  selenium-rc plug-in The long way – using Maven Handy to know  if you are working  with non-Grails web apps
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 Application is spun up within Grails running on top of servlet container Uses actual underlying framework instead of mocks Slower to run due to overhead of spinning up Grails 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 Grails App Real http requests Separate client Mock http requests Client requests from same process Real Hibernate Mock Hibernate Functionality Package or class level scope Launch Grails container 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 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 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)
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
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
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);
Grails Selenium-rc Plugin Advantages: really easy to install and start using Disadvantages: Very new, not extremely well field tested AFAIK, no way to run HTML-based tests  In other words, tests authored in the Selenium IDE must be converted to Java first
Lab 2: Grails Selenium-rc Plugin Create the App  grails create-app books  cd books  grails create-domain-class com.Book  grails generate-all com.Book  Make sure it launches as expected  grails run-app   (see the familiar ‘Welcome to Grails’ message)  Install plugin and Create Test  Type  grails install-plugin selenium-rc  Open up grails-app/conf/Config.groovy and ensure that  the grails.serverURL property is defined for every enviornment (production, development, and test.) If this property is undefined I’ve  seen strange problems occur when test tests are run.  Open an editor on the file test/selenium/HomePageTests.groovy, then type : You can copy and paste the commands, and the  Groovy code for the test class.  Please go to this page for the text to copy -> http://buildchimp.com/wordpress/?p=241
Lab 2: Grails Selenium-rc Plugin Run the Tests to Verify Success, Then Deliberately Introduce a Failure  Type  grails test-app This will run all unit, functional and integration tests. You should see the browser pop up briefly and the tests should pass. To verify that you are testing what you think you are testing, you will now deliberately introduce  a test failure.  Open the file ./grails-app/views/index.gsp and replace all occurrences of ‘Welcome to Grails’ with ‘Welcome to Jail’. Run  grails clean grails test-app Note that the Tests FAILED message is now visible. In the last page of your output you should also see the message:  testHomePageLoads…FAILED To see a detailed stack trace at the point of failure, open your folder browser on the folder  test/reports/plain.  View the file  TEST-HomePageTests.txt and you should see a stack trace that describes the assertion that failed.
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

What's hot (20)

PDF
Selenium Handbook
Suresh Thammishetty
 
PPT
Maven Overview
FastConnect
 
PDF
Testing with Codeception
Jeremy Coates
 
PDF
Maven tutorial
James Cellini
 
PDF
Testing with Codeception (Webelement #30)
Adam Štipák
 
PPT
Testing Java Web Apps With Selenium
Marakana Inc.
 
PDF
Efficient JavaScript Unit Testing, JavaOne China 2013
Hazem Saleh
 
PPTX
CI / CD w/ Codeception
Tudor Barbu
 
ODP
An Introduction to Maven Part 1
MD Sayem Ahmed
 
PDF
Efficient JavaScript Unit Testing, May 2012
Hazem Saleh
 
PDF
Codeception introduction and use in Yii
IlPeach
 
PDF
Selenium webdriver interview questions and answers
ITeLearn
 
PPTX
An Introduction to Maven
Vadym Lotar
 
PPTX
Test automation with php codeception
buddhieash
 
PDF
Automation Testing using Selenium
Naresh Chintalcheru
 
PPTX
Introduction to Maven
Onkar Deshpande
 
PPTX
[AnDevCon 2016] Mutation Testing for Android
Hazem Saleh
 
PDF
Test-driven Development with Drupal and Codeception (DrupalCamp Brighton)
Cogapp
 
PDF
Introducing Playwright's New Test Runner
Applitools
 
KEY
Enterprise Build And Test In The Cloud
Carlos Sanchez
 
Selenium Handbook
Suresh Thammishetty
 
Maven Overview
FastConnect
 
Testing with Codeception
Jeremy Coates
 
Maven tutorial
James Cellini
 
Testing with Codeception (Webelement #30)
Adam Štipák
 
Testing Java Web Apps With Selenium
Marakana Inc.
 
Efficient JavaScript Unit Testing, JavaOne China 2013
Hazem Saleh
 
CI / CD w/ Codeception
Tudor Barbu
 
An Introduction to Maven Part 1
MD Sayem Ahmed
 
Efficient JavaScript Unit Testing, May 2012
Hazem Saleh
 
Codeception introduction and use in Yii
IlPeach
 
Selenium webdriver interview questions and answers
ITeLearn
 
An Introduction to Maven
Vadym Lotar
 
Test automation with php codeception
buddhieash
 
Automation Testing using Selenium
Naresh Chintalcheru
 
Introduction to Maven
Onkar Deshpande
 
[AnDevCon 2016] Mutation Testing for Android
Hazem Saleh
 
Test-driven Development with Drupal and Codeception (DrupalCamp Brighton)
Cogapp
 
Introducing Playwright's New Test Runner
Applitools
 
Enterprise Build And Test In The Cloud
Carlos Sanchez
 

Similar to Selenium-Browser-Based-Automated-Testing-for-Grails-Apps (20)

PDF
Webtests Reloaded - Webtest with Selenium, TestNG, Groovy and Maven
Thorsten Kamann
 
KEY
Enterprise Build And Test In The Cloud
Carlos Sanchez
 
ODP
WebTest - Efficient Functional Web Testing with HtmlUnit and Beyond
mguillem
 
PPTX
Selenium Testing
Shreshtt Bhatt
 
DOC
Sel
Sandeep A R
 
PPTX
Selenium – testing tool jack
Jackseen Jeyaluck
 
PDF
full-stack-webapp-testing-with-selenium-and-rails.pdf
Brian Takita
 
PDF
Continuous Test Automation, by Richard Langlois P. Eng. and Yuri Pechenko.
Richard Langlois P. Eng.
 
PDF
Tellurium.A.New.Approach.For.Web.Testing
John.Jian.Fang
 
PDF
Selenium
g2ix
 
PPT
190711_Testbirds_Selenium_eclipsecon_FINAL_0.ppt
NaviAningi
 
PPT
KKSD_Testbirds_Selenium_eclipsecon_FINAL_0.ppt
Kiran Kumar SD
 
KEY
Testing with Jenkins, Selenium and Continuous Deployment
Max Klymyshyn
 
PDF
Tellurium.A.New.Approach.For.Web.Testing.V5
John.Jian.Fang
 
ZIP
Browser-Based testing using Selenium
ret0
 
PPTX
Automated testing with Drupal
Promet Source
 
ODP
Mastering selenium for automated acceptance tests
Nick Belhomme
 
PPT
Selenium and The Grinder
OpenSource Connections
 
PPTX
Selenium training
Suresh Arora
 
PPT
Automated Testing Of Web Applications Using XML
diongillard
 
Webtests Reloaded - Webtest with Selenium, TestNG, Groovy and Maven
Thorsten Kamann
 
Enterprise Build And Test In The Cloud
Carlos Sanchez
 
WebTest - Efficient Functional Web Testing with HtmlUnit and Beyond
mguillem
 
Selenium Testing
Shreshtt Bhatt
 
Selenium – testing tool jack
Jackseen Jeyaluck
 
full-stack-webapp-testing-with-selenium-and-rails.pdf
Brian Takita
 
Continuous Test Automation, by Richard Langlois P. Eng. and Yuri Pechenko.
Richard Langlois P. Eng.
 
Tellurium.A.New.Approach.For.Web.Testing
John.Jian.Fang
 
Selenium
g2ix
 
190711_Testbirds_Selenium_eclipsecon_FINAL_0.ppt
NaviAningi
 
KKSD_Testbirds_Selenium_eclipsecon_FINAL_0.ppt
Kiran Kumar SD
 
Testing with Jenkins, Selenium and Continuous Deployment
Max Klymyshyn
 
Tellurium.A.New.Approach.For.Web.Testing.V5
John.Jian.Fang
 
Browser-Based testing using Selenium
ret0
 
Automated testing with Drupal
Promet Source
 
Mastering selenium for automated acceptance tests
Nick Belhomme
 
Selenium and The Grinder
OpenSource Connections
 
Selenium training
Suresh Arora
 
Automated Testing Of Web Applications Using XML
diongillard
 
Ad

Recently uploaded (20)

PDF
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PDF
Automating Feature Enrichment and Station Creation in Natural Gas Utility Net...
Safe Software
 
PDF
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
DOCX
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
PPTX
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
PDF
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
PDF
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
Staying Human in a Machine- Accelerated World
Catalin Jora
 
PDF
What’s my job again? Slides from Mark Simos talk at 2025 Tampa BSides
Mark Simos
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PDF
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PDF
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
PPTX
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
PPTX
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
PDF
How do you fast track Agentic automation use cases discovery?
DianaGray10
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
PPTX
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
Automating Feature Enrichment and Station Creation in Natural Gas Utility Net...
Safe Software
 
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
Staying Human in a Machine- Accelerated World
Catalin Jora
 
What’s my job again? Slides from Mark Simos talk at 2025 Tampa BSides
Mark Simos
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
How do you fast track Agentic automation use cases discovery?
DianaGray10
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 
Ad

Selenium-Browser-Based-Automated-Testing-for-Grails-Apps

  • 1. - Selenium - Browser-Based Automated Testing of Grails Apps 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 Cargo Viewing Test Results Lab 1 – maven project Alternative Automation Strategies grails-selenium-rc plugin Lab 2 – using selenium-rc plugin How to write functional tests with Selenium KEY TAKE-AWAYS How to set up Selenium Testing On Grails Apps In Continuous Integration The fast way, using the grails- selenium-rc plug-in The long way – using Maven Handy to know if you are working with non-Grails web apps
  • 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 Application is spun up within Grails running on top of servlet container Uses actual underlying framework instead of mocks Slower to run due to overhead of spinning up Grails 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 Grails App Real http requests Separate client Mock http requests Client requests from same process Real Hibernate Mock Hibernate Functionality Package or class level scope Launch Grails container 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 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 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. 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
  • 12. 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
  • 13. Canoo Web Test Reports Canoo's reports show overall test results and let you drill down into any test
  • 14. Canoo Web Test Reports (cont.) Click to review a copy of the response HTML page corresponding to the first test step that failed
  • 15. 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)
  • 16. deploy Compile Unit Test Integration Test Package .war file Download And Install Tomcat
  • 17. 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
  • 18. 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
  • 19. Maven pom.xml – Nested Module Structure
  • 20. Maven pom.xml – Dependency Relationships Maven Repository org.example:demo:1.1
  • 21. 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
  • 22. 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);
  • 23. Grails Selenium-rc Plugin Advantages: really easy to install and start using Disadvantages: Very new, not extremely well field tested AFAIK, no way to run HTML-based tests In other words, tests authored in the Selenium IDE must be converted to Java first
  • 24. Lab 2: Grails Selenium-rc Plugin Create the App grails create-app books cd books grails create-domain-class com.Book grails generate-all com.Book Make sure it launches as expected grails run-app   (see the familiar ‘Welcome to Grails’ message) Install plugin and Create Test Type grails install-plugin selenium-rc Open up grails-app/conf/Config.groovy and ensure that  the grails.serverURL property is defined for every enviornment (production, development, and test.) If this property is undefined I’ve  seen strange problems occur when test tests are run. Open an editor on the file test/selenium/HomePageTests.groovy, then type : You can copy and paste the commands, and the Groovy code for the test class. Please go to this page for the text to copy -> http://buildchimp.com/wordpress/?p=241
  • 25. Lab 2: Grails Selenium-rc Plugin Run the Tests to Verify Success, Then Deliberately Introduce a Failure Type grails test-app This will run all unit, functional and integration tests. You should see the browser pop up briefly and the tests should pass. To verify that you are testing what you think you are testing, you will now deliberately introduce  a test failure. Open the file ./grails-app/views/index.gsp and replace all occurrences of ‘Welcome to Grails’ with ‘Welcome to Jail’. Run grails clean grails test-app Note that the Tests FAILED message is now visible. In the last page of your output you should also see the message: testHomePageLoads…FAILED To see a detailed stack trace at the point of failure, open your folder browser on the folder test/reports/plain. View the file  TEST-HomePageTests.txt and you should see a stack trace that describes the assertion that failed.
  • 27. 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.

Editor's Notes

  • #14: Canoo’s test results reports really excel at providing you drill down capability into the exact step of a test that failed. With Canoo’s reports you see a clickable entries for each test run toward the bottom of the page together with a summary of tests run. (pass fail percentages of both tests and individual steps within tests). If you click on an entry for an individual test, you see a page…. (next slide)…
  • #15: That gives you the pass/fail status of each individual step within the test. You can go right to the failing test and view the resulting response page from the server.. Then you can figure out why the returned content did not match your assertions about what that content should have been.
  • #22: Canoo’s test results reports really excel at providing you drill down capability into the exact step of a test that failed. With Canoo’s reports you see a clickable entries for each test run toward the bottom of the page together with a summary of tests run. (pass fail percentages of both tests and individual steps within tests). If you click on an entry for an individual test, you see a page…. (next slide)…