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
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 1

Writing reliable end to end tests

slide-2
SLIDE 2
slide-3
SLIDE 3

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

slide-4
SLIDE 4

End to End Integration Unit Tests

Unit tests are important but they aren’t “tests” they are part of the development process.

End to end Integration Unit tests

slide-5
SLIDE 5

Why is end to end testing important?

Tests whether the flow

  • f an application is

performing as designed from start to finish.

slide-6
SLIDE 6

Goal

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

slide-7
SLIDE 7
slide-8
SLIDE 8

Whit

slide-9
SLIDE 9

TLDR;

Reasons

Solutions

slide-10
SLIDE 10
slide-11
SLIDE 11

Research

slide-12
SLIDE 12

Over Engineering

slide-13
SLIDE 13

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

slide-14
SLIDE 14

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”); }

slide-15
SLIDE 15

class GoogleHomePage { 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") }

Noise Not so simple Test

slide-16
SLIDE 16
  • 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

slide-17
SLIDE 17

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

slide-18
SLIDE 18

class GoogleHomePage { 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") }

Not so simple Test

slide-19
SLIDE 19
slide-20
SLIDE 20

✓ Eliminate design ✓ Think like a user

slide-21
SLIDE 21

* Step ## Scenario # Specification

slide-22
SLIDE 22

* Step ## Scenario # Specification

slide-23
SLIDE 23

# Search the internet ## Search Google

* Goto “google.com" * Search for “QCon London” * Verify “Qcon London” on the

first page

slide-24
SLIDE 24

# 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

slide-25
SLIDE 25
slide-26
SLIDE 26

# Search the internet ## Search Google

* Goto “google.com” * Search for “QCon London”

## Search Duck * Goto “duck.com”
 * Search for “QCon London”

@Step("Goto <site>") public void goto(String site) { driver.get(site); } @Step(“Search for <query>”) public void goto(String query) { WebElement element =

driver .findElement(By.name(“q”)); element.sendKeys(query); element.submit(); }

slide-27
SLIDE 27
slide-28
SLIDE 28

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

slide-29
SLIDE 29

✓ Reduced code ✓ Readability ✓ User empathy ✓ Quick feedback

slide-30
SLIDE 30

Flakiness

Selectors

Source based Intrusive

By.Id(“pressMe”) By.Name(“pressMe”)

Structural

By.xpath(“//html/body/button”)

Waits

Explicit wait Implicit

Driver.findElement(…).click() wait = new WebDriverWait(driver, 20); wait.until(…)

Fluent wait

new FluentWait(WebDriver reference) .withTimeout(timeout, SECONDS) .pollingEvery(timeout, SECONDS)

slide-31
SLIDE 31

Smart Locators

click(“PRESS ME”)

slide-32
SLIDE 32

Smart Locators

write(“Qcon”)

slide-33
SLIDE 33

Proximity Selectors

click(checkbox(near(“Accept terms and conditions)))

slide-34
SLIDE 34
slide-35
SLIDE 35

# Search the internet # Search Google

* Go to "google.com" * Search for “qcon” * Verify

step(“Go to <website>”, (website) => { goto(website): });
 
 step(“Search for <query>”, (query) => { write(query); press(‘Enter’); });

slide-36
SLIDE 36

gauge.org

taiko.gauge.org

gocd.org

@getgauge

slide-37
SLIDE 37

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

slide-38
SLIDE 38

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

Concepts Specification