Anay - Fluent interfaces in testing
Upcoming SlideShare
Loading in...5
×
 

Anay - Fluent interfaces in testing

on

  • 1,491 views

Anay Nayak

Anay Nayak
Organization: ThoughtWorks
Topic: Fluent interfaces in testing
Presented in vodQA - THE TESTING SPIRIT! on Oct 7, 2010 in ThoughtWorks, Pune

Statistics

Views

Total Views
1,491
Views on SlideShare
1,491
Embed Views
0

Actions

Likes
0
Downloads
8
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Anay - Fluent interfaces in testing Anay - Fluent interfaces in testing Presentation Transcript

    • Fluent Interfaces in Testing
    • @Test public void testCheckResults() { startSeleniumSession("localhost", 8000, "firefox", "www.google.com"); Selenium selenium = session(); selenium.type("//input[@name="search"]", "vodQA infusion"); selenium.click("//form[@id='search']/a/span[text()='Go']"); selenium.waitForPageToLoad("300000"); selenium.isElementPresent("//div[@class='resultStats']"); verifyTrue(session().isTextPresent("the testing spirit")); }
    • @Test public void shouldReturnResultsForGivenQuery() { new HomePage() .enterSearchString("vodQA infusion").search() .validateResultsDisplayed() .validateSearchResult("the testing spirit"); } http://code.google.com/p/selenium/wiki/PageObjects @Test public void testCheckResults() { startSeleniumSession("localhost", 8000, "firefox", "www.google.com"); Selenium selenium = session(); selenium.type("//input[@name="search"]", "vodQA infusion"); selenium.click("//form[@id='search']/a/span[text()='Go']"); selenium.waitForPageToLoad("300000"); selenium.isElementPresent("//div[@class='resultStats']"); verifyTrue(session().isTextPresent("the testing spirit")); }
    • Fluent Interface? @Test public void shouldReturnResultsForGivenQuery() { new HomePage() .enterSearchString("vodQA infusion").search() .validateResultsDisplayed() .validateSearchResult("the testing spirit"); }
    • Confused?
    • A different example import static org.openqa.selenium.lift.Finders.*; import static org.openqa.selenium.lift.Matchers.*; ... @Test public void testHasAnImageSearchPage() { goTo("http://www.google.com"); assertPresenceOf(link("Images")); assertPresenceOf(atLeast(4), links().with(text(not(equalTo("Images"))))); clickOn(link("Images")); assertPresenceOf(title().with(text(equalTo("Google Image Search")))); } http://code.google.com/p/selenium/wiki/LiftStyleApi https://lift.dev.java.net/
    • assertThat
    • Examples assertThat(searchResultsCount, greaterThan(10)); assertThat(username, equalTo("Anay")); assertThat(currentTimeText, startsWith("Local time:")); assertThat(basket, new IsCollectionContaining<String>(equalTo("apples"))); assertThat(xml, hasXPath("/root/@type", equalTo("food")));
    • Matchers http://code.google.com/p/hamcrest/wiki/Tutorial
    • Thank You anayak@thoughtworks.com