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

Like this? Share it with your network

Share

Anay - Fluent interfaces in testing

  • 1,623 views
Uploaded on

Anay Nayak ...

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

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
1,623
On Slideshare
1,623
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
8
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Fluent Interfaces in Testing
  • 2. @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")); }
  • 3. @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")); }
  • 4. Fluent Interface? @Test public void shouldReturnResultsForGivenQuery() { new HomePage() .enterSearchString("vodQA infusion").search() .validateResultsDisplayed() .validateSearchResult("the testing spirit"); }
  • 5. Confused?
  • 6. 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/
  • 7. assertThat
  • 8. 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")));
  • 9. Matchers http://code.google.com/p/hamcrest/wiki/Tutorial
  • 10. Thank You anayak@thoughtworks.com