Make Everyone a Tester: Natural Language Acceptance Testing
-
Upload
viget-labs -
Category
Technology
-
view
1.162 -
download
0
description
Transcript of Make Everyone a Tester: Natural Language Acceptance Testing
![Page 1: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/1.jpg)
Make Everyone a TesterNatural Language Acceptance Testing
![Page 2: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/2.jpg)
![Page 3: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/3.jpg)
Dev
DesignUX
PM
![Page 4: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/4.jpg)
QA
QA
![Page 5: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/5.jpg)
why test?
![Page 6: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/6.jpg)
ensure quality
![Page 7: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/7.jpg)
communicate
![Page 8: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/8.jpg)
goals
• developer & PM pairing
• tests written first
• drive a web browser
![Page 9: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/9.jpg)
start with a storyUsers can register for an account
Requires the following information:
* Email* Password* Password Confirmation* Acceptance of terms / conditions
Acceptance Criteria
* Try with a duplicate email address* Try with a password less than 6 characters
![Page 10: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/10.jpg)
image: papazimouris @ flickr
![Page 11: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/11.jpg)
discussUsers can register for an account
Requires the following information:
* Email* Password* Password Confirmation* Acceptance of terms / conditions
Acceptance Criteria
* Try with a duplicate email address* Try with a password less than 6 characters
![Page 12: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/12.jpg)
discussUsers can register for an account
Requires the following information:
* Email* Password* Password Confirmation* Acceptance of terms / conditions
Acceptance Criteria
* Try with a duplicate email address* Try with a password less than 6 characters
form with data fields
![Page 13: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/13.jpg)
discussUsers can register for an account
Requires the following information:
* Email* Password* Password Confirmation* Acceptance of terms / conditions
Acceptance Criteria
* Try with a duplicate email address* Try with a password less than 6 characters
form with data fields
success state
![Page 14: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/14.jpg)
discussUsers can register for an account
Requires the following information:
* Email* Password* Password Confirmation* Acceptance of terms / conditions
Acceptance Criteria
* Try with a duplicate email address* Try with a password less than 6 characters
form with data fields
success state
error states
![Page 15: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/15.jpg)
define behavior
• locations
• page state
• message content
![Page 16: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/16.jpg)
State:
* No users exist in the system
Steps:
1. Visit the registration page2. Enter valid registration information3. Submit the form
Expectation:
* I should be redirected to the home page* I should see a success message displayed
where am I starting from?
![Page 17: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/17.jpg)
State:
* No users exist in the system
Steps:
1. Visit the registration page2. Enter valid registration information3. Submit the form
Expectation:
* I should be redirected to the home page* I should see a success message displayed
what are the inputs?
![Page 18: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/18.jpg)
State:
* No users exist in the system
Steps:
1. Visit the registration page2. Enter valid registration information3. Submit the form
Expectation:
* I should be redirected to the home page* I should see a success message displayed
what is the behavior?
![Page 19: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/19.jpg)
manual
![Page 20: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/20.jpg)
problems
• time consuming
• prone to error
• no regressions
![Page 21: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/21.jpg)
automate!
![Page 22: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/22.jpg)
![Page 23: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/23.jpg)
![Page 24: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/24.jpg)
done.
![Page 25: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/25.jpg)
but...
![Page 26: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/26.jpg)
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head profile="http://selenium-ide.openqa.org/profiles/test-case"><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><link rel="selenium.base" href="http://spasibo.com/" /><title>spasibo-test</title></head><body><table cellpadding="1" cellspacing="1" border="1"><thead><tr><td rowspan="1" colspan="3">spasibo-test</td></tr></thead><tbody><tr> <td>open</td> <td>/</td> <td></td></tr><tr> <td>clickAndWait</td> <td>link=Register</td> <td></td></tr><tr> <td>type</td> <td>user_email</td> <td>[email protected]</td></tr><tr> <td>type</td> <td>user_password</td> <td>password</td></tr><tr> <td>type</td> <td>user_password_confirmation</td> <td>password</td></tr><tr> <td>click</td> <td>user_terms</td> <td></td></tr><tr> <td>clickAndWait</td> <td>user_submit</td> <td></td></tr><tr> <td>waitForPageToLoad</td> <td>5000</td> <td></td></tr><tr> <td>verifyTextPresent</td> <td>Welcome to Spasibo. A winner is you!</td> <td></td></tr><tr> <td>verifyLocation</td> <td>http://spasibo.com/</td> <td></td></tr>
</tbody></table></body></html>
![Page 27: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/27.jpg)
![Page 28: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/28.jpg)
![Page 29: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/29.jpg)
problems
• not maintainable
• not reusable
• not understandable
![Page 30: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/30.jpg)
Selenium Remote Control
![Page 31: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/31.jpg)
write automated web application tests in a familiar
language and have them run in the browser
![Page 32: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/32.jpg)
![Page 33: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/33.jpg)
![Page 34: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/34.jpg)
$ java -jar selenium-server.jar 12:51:31.262 INFO - Java: Apple Inc. 1.5.0_16-13312:51:31.263 INFO - OS: Mac OS X 10.5.6 i38612:51:31.270 INFO - v1.0-beta-2 [2571], with Core v1.0-beta-2 [2330]12:51:31.394 INFO - Version Jetty/5.1.x12:51:31.395 INFO - Started HttpContext[/,/]12:51:31.396 INFO - Started HttpContext[/selenium-server,/selenium-server]12:51:31.397 INFO - Started HttpContext[/selenium-server/driver,/selenium-server/driver]12:51:31.408 INFO - Started SocketListener on 0.0.0.0:444412:51:31.408 INFO - Started org.mortbay.jetty.Server@bc887b
![Page 35: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/35.jpg)
class NewTest < Test::Unit::TestCase
... def test_new @selenium.open "/" @selenium.click "link=Register" @selenium.wait_for_page_to_load "30000" @selenium.type "user_email", "[email protected]" @selenium.type "user_password", "password" @selenium.type "user_password_confirmation", "password" @selenium.click "user_terms" @selenium.click "user_submit" @selenium.wait_for_page_to_load "30000" @selenium.wait_for_page_to_load "5000" begin assert @selenium.is_text_present("Welcome to Spasibo. A winner is you!") rescue Test::Unit::AssertionFailedError @verification_errors << $! end begin assert_equal "http://spasibo.com/", @selenium.get_location rescue Test::Unit::AssertionFailedError @verification_errors << $! end endend
![Page 36: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/36.jpg)
![Page 37: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/37.jpg)
$ gem install Selenium
![Page 38: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/38.jpg)
export the test
![Page 39: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/39.jpg)
require "selenium"require "test/unit"require "open-uri"
class NewTest < Test::Unit::TestCase def setup base_url = "http://spasibo.com/" open("#{base_url}setup/clean_slate") @verification_errors = [] if $selenium @selenium = $selenium else @selenium = Selenium::SeleniumDriver.new("localhost", 4444, "*chrome", base_url, 10000); @selenium.start end @selenium.set_context("test_new") end def teardown @selenium.stop unless $selenium assert_equal [], @verification_errors end def test_new @selenium.open "/" @selenium.click "link=Register" @selenium.wait_for_page_to_load "30000" @selenium.type "user_email", "[email protected]" @selenium.type "user_password", "password" @selenium.type "user_password_confirmation", "password" @selenium.click "user_terms" @selenium.click "user_submit" @selenium.wait_for_page_to_load "30000" @selenium.wait_for_page_to_load "5000" begin assert @selenium.is_text_present("Welcome to Spasibo. A winner is you!") rescue Test::Unit::AssertionFailedError @verification_errors << $! end begin assert_equal "http://spasibo.com/", @selenium.get_location rescue Test::Unit::AssertionFailedError @verification_errors << $! end endend
![Page 40: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/40.jpg)
def setup
...
@selenium = Selenium::SeleniumDriver.new("localhost", 4444, "*chrome", base_url, 10000); @selenium.start
...
endhost
port
browser
start URL
timeout
setup
![Page 41: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/41.jpg)
def setup base_url = "http://spasibo.com/" open("#{base_url}setup/clean_slate") ...
end
no users exist in the system
![Page 42: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/42.jpg)
def setup base_url = "http://spasibo.com/" open("#{base_url}setup/clean_slate") ...
end
don’t do this in production
no users exist in the system
![Page 43: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/43.jpg)
1. visit the registration page
def test_new @selenium.open "/" @selenium.click "link=Register" @selenium.wait_for_page_to_load "30000" @selenium.type "user_email", "[email protected]" @selenium.type "user_password", "password" @selenium.type "user_password_confirmation", "password" @selenium.click "user_terms" @selenium.click "user_submit" @selenium.wait_for_page_to_load "30000" @selenium.wait_for_page_to_load "5000"
...
end
![Page 44: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/44.jpg)
2. enter valid information
def test_new @selenium.open "/" @selenium.click "link=Register" @selenium.wait_for_page_to_load "30000" @selenium.type "user_email", "[email protected]" @selenium.type "user_password", "password" @selenium.type "user_password_confirmation", "password" @selenium.click "user_terms" @selenium.click "user_submit" @selenium.wait_for_page_to_load "30000" @selenium.wait_for_page_to_load "5000"
...
end
![Page 45: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/45.jpg)
3. submit the form
def test_new @selenium.open "/" @selenium.click "link=Register" @selenium.wait_for_page_to_load "30000" @selenium.type "user_email", "[email protected]" @selenium.type "user_password", "password" @selenium.type "user_password_confirmation", "password" @selenium.click "user_terms" @selenium.click "user_submit" @selenium.wait_for_page_to_load "30000" @selenium.wait_for_page_to_load "5000"
...
end
![Page 46: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/46.jpg)
success message displayed
def test_new
...
begin assert @selenium.is_text_present("Welcome to Spasibo. A winner is you!") rescue Test::Unit::AssertionFailedError @verification_errors << $! end begin assert_equal "http://spasibo.com/", @selenium.get_location rescue Test::Unit::AssertionFailedError @verification_errors << $! endend
![Page 47: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/47.jpg)
user is redirected
def test_new
...
begin assert @selenium.is_text_present("Welcome to Spasibo. A winner is you!") rescue Test::Unit::AssertionFailedError @verification_errors << $! end begin assert_equal "http://spasibo.com/", @selenium.get_location rescue Test::Unit::AssertionFailedError @verification_errors << $! endend
![Page 48: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/48.jpg)
$ ruby -rubygems spasibo_test.rb Loaded suite spasibo_testStarted.Finished in 10.559078 seconds.
1 tests, 3 assertions, 0 failures, 0 errors
![Page 49: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/49.jpg)
problems
• dependent on a developer
• still not understandable
![Page 50: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/50.jpg)
State:
* No users exist in the system
Steps:
1. Visit the registration page2. Enter valid registration information3. Submit the form
Expectation:
* I should be redirected to the home page* I should see a success message displayed
![Page 51: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/51.jpg)
can I make that executable?
![Page 52: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/52.jpg)
![Page 53: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/53.jpg)
Behavior-Driven Development tool that speaks to domain
experts first and code second
![Page 54: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/54.jpg)
$ gem install cucumber
![Page 55: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/55.jpg)
tweak the language
![Page 56: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/56.jpg)
State:
* No users exist in the system
Steps:
1. Visit the registration page2. Enter valid registration information3. Submit the form
Expectation:
* I should be redirected to the home page* I should see a success message displayed
![Page 57: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/57.jpg)
State:
* Given no users exist in the system
Steps:
1. Visit the registration page2. Enter valid registration information3. Submit the form
Expectation:
* I should be redirected to the home page* I should see a success message displayed
![Page 58: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/58.jpg)
State:
* Given no users exist in the system
Steps:
1. When I visit the registration page2. And I enter valid registration information3. And I submit the form
Expectation:
* I should be redirected to the home page* I should see a success message displayed
![Page 59: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/59.jpg)
State:
* Given no users exist in the system
Steps:
1. When I visit the registration page2. And I enter valid registration information3. And I submit the form
Expectation:
* Then I should be redirected to the home page* And I should see a success message displayed
![Page 60: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/60.jpg)
State:
* Given no users exist in the system
Steps:
1. When I visit the registration page2. And I enter valid registration information3. And I submit the form
Expectation:
* Then I should be redirected to the home page* And I should see a success message displayed
![Page 61: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/61.jpg)
create a feature
![Page 62: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/62.jpg)
# features/registration.feature
Feature: User Registration In order to identify users in the system Users must be able to log in
Scenario: Successful Registration Given no users exist in the system When I visit the registration page And I enter valid registration information And I submit the form Then I should be redirected to the home page And I should see a success message displayed
![Page 63: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/63.jpg)
$ cucumber registration.feature
![Page 64: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/64.jpg)
You can implement step definitions for undefined steps with these snippets:
Given /^no users exist in the system$/ do pendingend
When /^I visit the registration page$/ do pendingend
When /^I enter valid registration information$/ do pendingend
When /^I submit the form$/ do pendingend
Then /^I should be redirected to the home page$/ do pendingend
Then /^I should see a success message displayed$/ do pendingend
![Page 65: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/65.jpg)
# steps/registration_steps.rb
Given /^no users exist in the system$/ do pendingend
When /^I visit the registration page$/ do pendingend
When /^I enter valid registration information$/ do pendingend
When /^I submit the form$/ do pendingend
Then /^I should be redirected to the home page$/ do pendingend
Then /^I should see a success message displayed$/ do pendingend
definitions
![Page 66: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/66.jpg)
# steps/registration_steps.rb
Given /^no users exist in the system$/ do open "#{BASE_URL}/setup/clean_slate"end
When /^I visit the registration page$/ do pendingend
When /^I enter valid registration information$/ do pendingend
When /^I submit the form$/ do pendingend
Then /^I should be redirected to the home page$/ do pendingend
Then /^I should see a success message displayed$/ do pendingend
state
![Page 67: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/67.jpg)
# steps/registration_steps.rb
Given /^no users exist in the system$/ do open "#{BASE_URL}/setup/clean_slate"end
When /^I visit the registration page$/ do @browser.open "/register"end
When /^I enter valid registration information$/ do @browser.type "user_email", "[email protected]" @browser.type "user_password", "password" @browser.type "user_password_confirmation", "password" @browser.click "user_terms"end
When /^I submit the form$/ do @browser.click "user_submit" @browser.wait_for_page_to_loadend
Then /^I should be redirected to the home page$/ do pendingend
Then /^I should see a success message displayed$/ do pendingend
steps
![Page 68: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/68.jpg)
# steps/registration_steps.rb
Given /^no users exist in the system$/ do open "#{BASE_URL}/setup/clean_slate"end
When /^I visit the registration page$/ do @browser.open "/register"end
When /^I enter valid registration information$/ do @browser.type "user_email", "[email protected]" @browser.type "user_password", "password" @browser.type "user_password_confirmation", "password" @browser.click "user_terms"end
When /^I submit the form$/ do @browser.click "user_submit" @browser.wait_for_page_to_loadend
Then /^I should be redirected to the home page$/ do assert_equal "#{BASE_URL}/", @browser.get_locationend
Then /^I should see a success message displayed$/ do assert @browser.is_text_present("Welcome to Spasibo. A winner is you!")end
expectation
![Page 69: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/69.jpg)
$ cucumber registration.feature Feature: User Registration In order to identify users in the system Users must be able to log in
Scenario: Successful registration # registration.feature:5 Given no users exist in the system # steps/registration_steps.rb:1 When I visit the registration page # steps/registration_steps.rb:5 And I enter valid registration information # steps/registration_steps.rb:9 And I submit the form # steps/registration_steps.rb:16 Then I should be redirected to the home page # steps/registration_steps.rb:21 And I should see a success message displayed # steps/registration_steps.rb:25
1 scenario (1 passed)6 steps (6 passed)
![Page 70: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/70.jpg)
problems
• dependent on a developer
• no control over input data
![Page 71: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/71.jpg)
# registration.feature
Feature: User Registration In order to identify users in the system Users must be able to log in
Scenario: Successful registration Given no users exist in the system When I visit "/register" And I enter "[email protected]" for "user_email" And I enter "password" for "user_password" And I enter "password" for "user_password_confirmation" And I check the "user_terms" box And I click the "user_submit" button Then I should be redirected to "/" And I should see the message "Welcome to Spasibo. A winner is you!"
![Page 72: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/72.jpg)
You can implement step definitions for undefined steps with these snippets:
Given /^no users exist in the system$/ do pendingend
When /^I visit "([^\"]*)"$/ do |arg1| pendingend
When /^I enter "([^\"]*)" for "([^\"]*)"$/ do |arg1, arg2| pendingend
When /^I check the "([^\"]*)" box$/ do |arg1| pendingend
When /^I click the "([^\"]*)" button$/ do |arg1| pendingend
Then /^I should be redirected to "([^\"]*)"$/ do |arg1| pendingend
Then /^I should see the message "([^\"]*)"$/ do |arg1| pendingend
![Page 73: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/73.jpg)
# steps/registration_steps.rb
Given /^no users exist in the system$/ do pendingend
When /^I visit "([^\"]*)"$/ do |arg1| pendingend
When /^I enter "([^\"]*)" for "([^\"]*)"$/ do |arg1, arg2| pendingend
When /^I check the "([^\"]*)" box$/ do |arg1| pendingend
When /^I click the "([^\"]*)" button$/ do |arg1| pendingend
Then /^I should be redirected to "([^\"]*)"$/ do |arg1| pendingend
Then /^I should see the message "([^\"]*)"$/ do |arg1| pendingend
definitions
![Page 74: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/74.jpg)
# steps/registration_steps.rb
Given /^no users exist in the system$/ do open "#{BASE_URL}/setup/clean_slate"end
When /^I visit "([^\"]*)"$/ do |arg1| pendingend
When /^I enter "([^\"]*)" for "([^\"]*)"$/ do |arg1, arg2| pendingend
When /^I check the "([^\"]*)" box$/ do |arg1| pendingend
When /^I click the "([^\"]*)" button$/ do |arg1| pendingend
Then /^I should be redirected to "([^\"]*)"$/ do |arg1| pendingend
Then /^I should see the message "([^\"]*)"$/ do |arg1| pendingend
state
![Page 75: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/75.jpg)
# steps/registration_steps.rb
Given /^no users exist in the system$/ do open "#{BASE_URL}/setup/clean_slate"end
When /^I visit "([^\"]*)"$/ do |path| @browser.open pathend
When /^I enter "([^\"]*)" for "([^\"]*)"$/ do |value, text_field_id| @browser.type text_field_id, valueend
When /^I check the "([^\"]*)" box$/ do |checkbox_id| @browser.check checkbox_idend
When /^I click the "([^\"]*)" button$/ do |submit_button_id| @browser.click submit_button_id @browser.wait_for_page_to_loadend
Then /^I should be redirected to "([^\"]*)"$/ do |arg1| pendingend
Then /^I should see the message "([^\"]*)"$/ do |arg1| pendingend
steps
![Page 76: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/76.jpg)
# steps/registration_steps.rb
Given /^no users exist in the system$/ do open "#{BASE_URL}/setup/clean_slate"end
When /^I visit "([^\"]*)"$/ do |path| @browser.open pathend
When /^I enter "([^\"]*)" for "([^\"]*)"$/ do |value, text_field_id| @browser.type text_field_id, valueend
When /^I check the "([^\"]*)" box$/ do |checkbox_id| @browser.check checkbox_idend
When /^I click the "([^\"]*)" button$/ do |submit_button_id| @browser.click submit_button_id @browser.wait_for_page_to_loadend
Then /^I should be redirected to "([^\"]*)"$/ do |path| assert_equal "#{BASE_URL}#{path}", @browser.get_locationend
Then /^I should see the message "([^\"]*)"$/ do |message| assert @browser.is_text_present(message)end
expectation
![Page 77: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/77.jpg)
$ cucumber registration.feature Feature: User Registration In order to identify users in the system Users must be able to log in
Scenario: Successful registration # registration.feature:7 Given no users exist in the system # steps/registration_steps.rb:1 When I visit "/register" # steps/registration_steps.rb:5 And I enter "[email protected]" for "user_email" # steps/registration_steps.rb:9 And I enter "password" for "user_password" # steps/registration_steps.rb:9 And I enter "password" for "user_password_confirmation" # steps/registration_steps.rb:9 And I check the "user_terms" box # steps/registration_steps.rb:13 And I click the "user_submit" button # steps/registration_steps.rb:17 Then I should be redirected to "/" # steps/registration_steps.rb:22 And I should see the message "Welcome to Spasibo. A winner is you!" # steps/registration_steps.rb:26
1 scenario (1 passed)9 steps (9 passed)
![Page 78: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/78.jpg)
extend
![Page 79: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/79.jpg)
Scenario: No data supplied Given no users exist in the system When I visit "/register" And I click the "user_submit" button Then I should be redirected to "/register" And I should see the message "NYET! A FAIL IS YOU" And I should see the message "Email can't be blank" And I should see the message "Terms must be accepted" Scenario: Password not confirmed Given no users exist in the system When I visit "/register" And I enter "[email protected]" for "user_email" And I enter "password" for "user_password" And I enter "drowssap" for "user_password_confirmation" And I check the "user_terms" box And I click the "user_submit" button Then I should be redirected to "/register" And I should see the message "NYET! A FAIL IS YOU" And I should see the message "Password doesn't match confirmation"
![Page 80: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/80.jpg)
Scenario: Successful registration with alternate data Given no users exist in the system When I visit "/register" And I enter "[email protected]" for "user_email" And I enter "password123" for "user_password" And I enter "password123" for "user_password_confirmation" And I check the "user_terms" box And I click the "user_submit" button Then I should be redirected to "/" And I should see the message "Welcome to Spasibo. A winner is you!"
![Page 81: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/81.jpg)
remove duplicationimage: haakseth @ flickr
![Page 82: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/82.jpg)
Scenario: Successful registration Given no users exist in the system When I visit "/register" And I enter "[email protected]" for "user_email" And I enter "password" for "user_password" And I enter "password" for "user_password_confirmation" And I check the "user_terms" box And I click the "user_submit" button Then I should be redirected to "/" And I should see the message "Welcome to Spasibo. A winner is you!"
![Page 83: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/83.jpg)
Scenario Outline: Successful registration Given no users exist in the system When I visit "/register" And I enter "[email protected]" for "user_email" And I enter "password" for "user_password" And I enter "password" for "user_password_confirmation" And I check the "user_terms" box And I click the "user_submit" button Then I should be redirected to "/" And I should see the message "Welcome to Spasibo. A winner is you!"
![Page 84: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/84.jpg)
Scenario Outline: Successful registration Given no users exist in the system When I visit "/register" And I enter "<email>" for "user_email" And I enter "<password>" for "user_password" And I enter "<password_confirmation>" for "user_password_confirmation" And I check the "user_terms" box And I click the "user_submit" button Then I should be redirected to "/" And I should see the message "Welcome to Spasibo. A winner is you!"
![Page 85: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/85.jpg)
Scenario Outline: Successful registration Given no users exist in the system When I visit "/register" And I enter "<email>" for "user_email" And I enter "<password>" for "user_password" And I enter "<password_confirmation>" for "user_password_confirmation" And I check the "user_terms" box And I click the "user_submit" button Then I should be redirected to "/" And I should see the message "Welcome to Spasibo. A winner is you!"
Examples: | email | password | password_confirmation | | [email protected] | password | password | | [email protected] | password123 | password123 |
![Page 86: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/86.jpg)
$ cucumber registration.feature Feature: User registration In order to identify users in the system Users must be able to log in
Scenario Outline: Successful Registration # registration.feature:7 Given no users exist in the system # steps/registration_steps.rb:1 When I visit "/register" # steps/registration_steps.rb:5 And I enter "<email>" for "user_email" # steps/registration_steps.rb:9 And I enter "<password>" for "user_password" # steps/registration_steps.rb:9 And I enter "<password_confirmation>" for "user_password_confirmation" # steps/registration_steps.rb:9 And I check the "user_terms" box # steps/registration_steps.rb:13 And I click the "user_submit" button # steps/registration_steps.rb:17 Then I should be redirected to "/" # steps/registration_steps.rb:22 And I should see the message "Welcome to Spasibo. A winner is you!" # steps/registration_steps.rb:26
Examples: | email | password | password_confirmation | | [email protected] | password | password | | [email protected] | password123 | password123 |
2 scenarios (2 passed)18 steps (18 passed)
![Page 87: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/87.jpg)
image: mediageek @ flickr
![Page 88: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/88.jpg)
future
![Page 89: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/89.jpg)
Scenario: Duplicate email address Given a user exists in the system with the email "[email protected]" When I visit "/register" And I enter valid registration information And I enter "[email protected]" for "user_email" And I click the "user_submit" button Then I should be redirected to "/register" And I should see the message "Email has already been taken"
refactor
![Page 90: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/90.jpg)
Scenario: Duplicate email address Given a user exists in the system with the email "[email protected]" When I visit "/register" And I enter valid registration information And I enter "[email protected]" for "user_email" And I click the "user_submit" button Then I should be redirected to "/register" And I should see the message "Email has already been taken"
refactor
![Page 91: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/91.jpg)
Given /^a user exists in the system with the email "([^\"]*)"$/ do |email| Given 'no users exist in the system' When 'I visit "/register"' When 'I enter valid registration information' When 'I enter "' + email + '" for "user_email"' When 'I click the "user_submit" button'end
When /^I enter valid registration information$/ do When 'I enter "[email protected]" for "user_email"' When 'I enter "password" for "user_password"' When 'I enter "password" for "user_password_confirmation"' When 'I check the "user_terms" box'end
refactor
![Page 92: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/92.jpg)
Scenario: Duplicate email address # registration.feature:51 Given a user exists in the system with the email "[email protected]" # steps/registration_steps.rb:30 When I visit "/register" # steps/registration_steps.rb:5 And I enter valid registration information # steps/registration_steps.rb:38 And I enter "[email protected]" for "user_email" # steps/registration_steps.rb:9 And I click the "user_submit" button # steps/registration_steps.rb:17 Then I should be redirected to "/register" # steps/registration_steps.rb:22 And I should see the message "Email has already been taken" # steps/registration_steps.rb:26
![Page 93: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/93.jpg)
run by name
$ cucumber registration.feature --name "Success"Feature: User Registration In order to identify users in the system Users must be able to log in
Scenario: Successful registration # registration.feature:7 Given no users exist in the system # steps/registration_steps.rb:1 When I visit "/register" # steps/registration_steps.rb:5 And I enter "[email protected]" for "user_email" # steps/registration_steps.rb:9 And I enter "password" for "user_password" # steps/registration_steps.rb:9 And I enter "password" for "user_password_confirmation" # steps/registration_steps.rb:9 And I check the "user_terms" box # steps/registration_steps.rb:13 And I click the "user_submit" button # steps/registration_steps.rb:17 Then I should be redirected to "/" # steps/registration_steps.rb:22 And I should see the message "Welcome to Spasibo. A winner is you!" # steps/registration_steps.rb:26
Scenario: Successful registration with alternate data # registration.feature:18 Given no users exist in the system # steps/registration_steps.rb:1 When I visit "/register" # steps/registration_steps.rb:5 And I enter "[email protected]" for "user_email" # steps/registration_steps.rb:9 And I enter "password123" for "user_password" # steps/registration_steps.rb:9 And I enter "password123" for "user_password_confirmation" # steps/registration_steps.rb:9 And I check the "user_terms" box # steps/registration_steps.rb:13 And I click the "user_submit" button # steps/registration_steps.rb:17 Then I should be redirected to "/" # steps/registration_steps.rb:22 And I should see the message "Welcome to Spasibo. A winner is you!" # steps/registration_steps.rb:26
2 scenarios (2 passed)18 steps (18 passed)
![Page 94: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/94.jpg)
tagging
@slow Scenario: Duplicate email address Given a user exists in the system with the email "[email protected]" When I visit "/register" And I enter valid registration information And I enter "[email protected]" for "user_email" And I click the "user_submit" button Then I should be redirected to "/register" And I should see the message "Email has already been taken"
![Page 95: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/95.jpg)
run by tag
$ cucumber registration.feature --tags @slowFeature: User Registration In order to identify users in the system Users must be able to log in
@slow Scenario: Duplicate email address # registration.feature:51 Given a user exists in the system with the email "[email protected]" # steps/registration_steps.rb:30 When I visit "/register" # steps/registration_steps.rb:5 And I enter valid registration information # steps/registration_steps.rb:38 And I enter "[email protected]" for "user_email" # steps/registration_steps.rb:9 And I click the "user_submit" button # steps/registration_steps.rb:17 Then I should be redirected to "/register" # steps/registration_steps.rb:22 And I should see the message "Email has already been taken" # steps/registration_steps.rb:26
1 scenario (1 passed)7 steps (7 passed)
![Page 96: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/96.jpg)
$ cucumber registration.feature --tags ~@slow
![Page 97: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/97.jpg)
cross platform
![Page 98: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/98.jpg)
continuous integration
![Page 99: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/99.jpg)
continuous integrationintegration?
![Page 100: Make Everyone a Tester: Natural Language Acceptance Testing](https://reader034.fdocuments.in/reader034/viewer/2022051612/54bd17f64a7959ff308b4655/html5/thumbnails/100.jpg)
Resources• Selenium: http://seleniumhq.org/
• Cucumber: http://cukes.info/
• Slides / Code: http://github.com/reagent/nlt
Contact• [email protected]
• http://twitter.com/reagent
image: nomeacuerdo @ flickr