writing reliable end to end tests end to end browser tests
play

Writing reliable end to end tests End to end browser tests They take - PowerPoint PPT Presentation

Writing reliable end to end tests End to end browser tests They take a long time to run. Around 4-12 hours Long feedback cycles Tough to read or modify Flaky Not part of the development life cycle Unit tests are End to end important but they End


  1. Writing reliable end to end tests

  2. End to end browser tests They take a long time to run. Around 4-12 hours Long feedback cycles Tough to read or modify Flaky Not part of the development life cycle

  3. Unit tests are End to end important but they End to End aren’t “tests” Integration they are part of Integration the development Unit Tests process. Unit tests

  4. Why is end to end testing important? Tests whether the flow of an application is performing as designed from start to finish.

  5. Goal Simulate what a real user scenario looks like from start to finish.

  6. Whit

  7. TLDR; Reasons Solutions

  8. Research

  9. Over Engineering

  10. void test() { driver.get(“google.com”); WebElement element = driver.findElement(By.name(“q”)); element.sendKeys("testing frameworks”); element.submit(); }

  11. void google(String query) { driver.get("google.com"); WebElement element = driver.findElement(By.name("q")); element.sendKeys(query); element.submit(); } void testOne() { google("automated testing"); } void testTwo() { google(“qcon london”); }

  12. class GoogleHomePage { Not so simple Test GoogleHomePage(Webdriver driver) { driver.get("google.com"); this.driver = driver; } void searchFor(String query) { WebElement element = driver.findElement(By.name("q")); Noise element.sendKeys("testing frameworks"); element.submit(); } } void testOne() { GoogleHomePage page = new GoogleHomePage(); page.searchFor("testing frameworks") } void testTwo() { GoogleHomePage page = new GoogleHomePage(); page.searchFor("flying foxes") }

  13. • Page Object Pattern • Advanced Page Object Pattern • Facade Design Pattern • Singleton Design Pattern • Fluent Page Object Pattern • IoC Container and Page Object • Strategy Design Pattern • Advanced Strategy Design Pattern • Observer Design Pattern • Observer Design Pattern via Events and Delegate • Observer Design Pattern via IObservable and IObserver

  14. Tester’s spend close to 50% of the time designing and maintaining test frameworks

  15. class GoogleHomePage { Not so simple Test GoogleHomePage(Webdriver driver) { driver.get("google.com"); this.driver = driver; } void searchFor(String query) { WebElement element = driver.findElement(By.name("q")); element.sendKeys("testing frameworks"); element.submit(); } } void testOne() { GoogleHomePage page = new GoogleHomePage(); page.searchFor("testing frameworks") } void testTwo() { GoogleHomePage page = new GoogleHomePage(); page.searchFor("flying foxes") }

  16. ✓ Eliminate design ✓ Think like a user

  17. # Specification ## Scenario * Step

  18. # Specification ## Scenario * Step

  19. # Search the internet ## Search Google * Goto “google.com" * Search for “QCon London” * Verify “Qcon London” on the first page

  20. # Search the internet ## Search Google * Goto “google.com" 
 * Search for “QCon London” 
 * Verify “Qcon London” is on the first page ## Search Duck * Goto “duck.com” 
 * Search for “QCon London” 
 * Verify “Qcon London” is on the first page

  21. @Step("Goto <site>") public void goto(String site) { # Search the internet driver.get(site); } ## Search Google * Goto “google.com” @Step(“Search for <query>”) * Search for “QCon London” public void goto(String query) { WebElement element = driver ## Search Duck .findElement(By.name(“q”)); * Goto “duck.com” 
 element.sendKeys(query); * Search for “QCon London” element.submit(); }

  22. ✓ Single binary install ✓ Customisable reports ✓ Data driven tests ✓ Plugins ✓ Parallel execution ✓ Support for all IDE’s and languages

  23. ✓ Reduced code ✓ Readability ✓ User empathy ✓ Quick feedback

  24. Flakiness Waits Selectors Implicit Intrusive Driver.findElement(…).click() By.Id(“pressMe”) Explicit wait Source based wait = new WebDriverWait(driver, 20); By.Name(“pressMe”) wait.until(…) Structural Fluent wait new FluentWait(WebDriver reference) By.xpath(“//html/body/button”) .withTimeout(timeout, SECONDS) .pollingEvery(timeout, SECONDS)

  25. Smart Locators click(“PRESS ME”)

  26. Smart Locators write(“Qcon”)

  27. Proximity Selectors click(checkbox(near(“Accept terms and conditions)))

  28. 
 step(“Go to <website>”, (website) => { goto(website): }); 
 # Search the internet step(“Search for <query>”, (query) => { # Search Google write(query); * Go to "google.com" press(‘Enter’); * Search for “qcon” }); * Verify

  29. gauge.org @getgauge taiko.gauge.org gocd.org

  30. ✓ Gauge is not BDD ✓ Non prescriptive syntax 
 ✓ Parallel runs out of the box ✓ Screenshots on failure ✓ First class IDE Support ✓ Data stores, external data

  31. 
 
 
 Concepts Specification # Book <number> tickets # Search for movies 
 * Pick <number> seats 
 * Set location as "Bangalore" 
 * Login in as "John" 
 * Pay using credit card 
 ## Search for blockbusters 
 * Check ticket * Search for theatres playing "Avengers" 
 * Book "2" tickets ## Search 2017 Oscar winners 
 * Search for theaters playing "The shape of water" * Book "2" tickets

Recommend


More recommend