Your SlideShare is downloading. ×
0
Introduce cucumber
Introduce cucumber
Introduce cucumber
Introduce cucumber
Introduce cucumber
Introduce cucumber
Introduce cucumber
Introduce cucumber
Introduce cucumber
Introduce cucumber
Introduce cucumber
Introduce cucumber
Introduce cucumber
Introduce cucumber
Introduce cucumber
Introduce cucumber
Introduce cucumber
Introduce cucumber
Introduce cucumber
Introduce cucumber
Introduce cucumber
Introduce cucumber
Introduce cucumber
Introduce cucumber
Introduce cucumber
Introduce cucumber
Introduce cucumber
Introduce cucumber
Introduce cucumber
Introduce cucumber
Introduce cucumber
Introduce cucumber
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Introduce cucumber

1,651

Published on

It's easy

It's easy

Published in: Technology, Economy & Finance
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,651
On Slideshare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
29
Comments
0
Likes
1
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. Why should we use automatic test framework?
  • 2. A long long story…
  • 3. Why should we choose ?
  • 4. Test Driven Development
  • 5. cCan you understand it? No, I can’t
  • 6. Behavior Driven Development
  • 7. Feature:Now User has given all his basic info and decided which products he will buy, then heforward into the last process - pay the money. /registration/business_pay will summarize theprice(including tax and discount) he will pay and let user fill in his credit card info, when hepresses "Confirm", it will charge his credit card.Scenario: Now user input credit card info and press "Confirm", the page will submit his infoto AriaSystem, AriaSystem will validate his credit card info, charge his credit card and returnsome data to our database. Then our database will save his personal info and partner info. Ifall these work well, user will be redirected to /registration/business_finish. Given I reach /registration/business_pay When I fill in basic info into /registration/business_pay And I press "Confirm" Then I should see "Please wait..." And I waiting for being redirected to "/registration/business_finish" And all MozyPro data in Database is correct
  • 8. Everyone can read it
  • 9. Everyone can write itInclude people who don’t speak English
  • 10. How does it test?
  • 11. Open a real browser
  • 12. Behave as a real user
  • 13. Apply to any page, any website
  • 14. Not only BDD
  • 15. But also DDDDocument Driven Development
  • 16. Cucumber Style Document
  • 17. More secrets ?
  • 18. Step DefinitionsGiven /^I am in "([^"]*)"$/ do |url| visit mozy_url(url, :https => true)endThen /^I would be redirected to "([^"]*)"$/ do |url| page.current_url.shouldbe_include?mozy_url(url, :https => true)end
  • 19. Have a try ?Let’s write a simple Cucumber test case
  • 20. Sign up an Account
  • 21. Gemfilegroup :test do gem cucumber gem cucumber-rails, require: false gem capybara, git: https://github.com/jnicklas/capybara.git gem rspec #use rspec expectation gem Selenium #use firefox to test gem database_cleaner #clean database after each test caseend$ bundle install
  • 22. Install Cucumber$ rails generate cucumber:install create config/cucumber.yml create script/cucumber chmod script/cucumber create features/step_definitions create features/support create features/support/env.rb exist lib/tasks create lib/tasks/cucumber.rake gsub config/database.yml gsub config/database.yml force config/database.yml
  • 23. features/support/env.rbrequire cucumber/rails’Capybara.default_selector = :cssCapybara.default_driver = :selenium #add this lineActionController::Base.allow_rescue = falsebegin DatabaseCleaner.strategy = :transactionrescue NameError raise "You need to add database_cleaner to your Gemfile (in the :test group) if youwish to use it."EndCucumber::Rails::Database.javascript_strategy = :truncation
  • 24. features/sign_up.featureFeature: Sign up Scenario: I will register a user with email "zhour@vmware.com" andpassword "vmware” Given I fill in email "zhour@vmware.com" and password "vmware" in signup page When I press "Sign up" Then I should see "Page#index"
  • 25. $ rake cucumber
  • 26. features/step_definitions/sign_up.rb
  • 27. it works
  • 28. Firefox
  • 29. Thanks

×