Cucumber Presentation Kiev Meet Up

610 views
566 views

Published on

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

No Downloads
Views
Total views
610
On SlideShare
0
From Embeds
0
Number of Embeds
5
Actions
Shares
0
Downloads
5
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Cucumber Presentation Kiev Meet Up

  1. 2. Dima Kovalenko @dimacus www.agilesoftwaretesting.com www.dimakovalenko.com linked in.com/in/dimakovalen ko
  2. 3. Past Experience
  3. 4. Disclaimer > Dima.kind_of?(Developer) => false
  4. 5. Why automated tests?
  5. 6. Why automated tests? <ul><li>Too expensive </li></ul><ul><li>Too much work to create </li></ul><ul><li>Not enough staff to maintain </li></ul><ul><li>Never know the coverage level </li></ul><ul><li>No one but developers knows what is being tested </li></ul>
  6. 7. We don’t need Automated Tests!
  7. 8. We don’t need Automated Tests! The End See You all at Selenium 2012!
  8. 10. Selenium and Cucumber Img Source: http://pickledillies.homestead.com/
  9. 11. Overview <ul><li>Set the stage </li></ul><ul><li>Introduce Cucumber </li></ul><ul><li>Good features </li></ul><ul><li>Bad features </li></ul><ul><li>??? </li></ul><ul><li>Profit! </li></ul>
  10. 12. Assumptions <ul><li>Startup or small business </li></ul><ul><li>Understaffed </li></ul><ul><li>Inadequate test coverage </li></ul><ul><li>Need to defend existence of having automated tests to business. </li></ul>
  11. 13. The Stage
  12. 14. The Stage <ul><li>First casualty of an agile development environment is documentation. - me </li></ul>
  13. 15. The Stage <ul><li>First casualty of an agile development environment is documentation. - me </li></ul><ul><li>No written test cases to speak of </li></ul>
  14. 16. The Stage <ul><li>First casualty of an agile development environment is documentation. - me </li></ul><ul><li>No written test cases to speak of </li></ul><ul><li>Need to deliver features, NOW!!! </li></ul>
  15. 17. The Stage <ul><li>First casualty of an agile development environment is documentation. - me </li></ul><ul><li>No written test cases to speak of </li></ul><ul><li>Need to deliver features, NOW!!! </li></ul><ul><ul><li>Groupon: Weekly deployments </li></ul></ul>
  16. 18. The Stage <ul><li>First casualty of an agile development environment is documentation. - me </li></ul><ul><li>No written test cases to speak of </li></ul><ul><li>Need to deliver features, NOW!!! </li></ul><ul><ul><li>Groupon: Weekly deployments </li></ul></ul><ul><ul><li>IMVU: Up to 50 deploys a day </li></ul></ul><ul><ul><ul><li>http://timothyfitz.wordpress.com/2009/02/10/continuous-deployment-at-imvu-doing-the-impossible-fifty-times-a-day/ </li></ul></ul></ul>
  17. 19. Why automated tests? <ul><li>Too expensive </li></ul><ul><li>Too much work to create </li></ul><ul><li>Not enough staff to maintain </li></ul><ul><li>Never know the coverage level </li></ul><ul><li>No one but developers knows what is being tested </li></ul>
  18. 20. Cucumber
  19. 21. Cucumber <ul><li>A BDD framework to help with TDD and other TLAs </li></ul>
  20. 22. Cucumber <ul><li>A BDD framework to help with TDD and other TLAs </li></ul><ul><li>It’s Agile, Promotes Synergy, Enterprise, will shift Paradigms and completely Web 2.0 </li></ul>
  21. 23. Cucumber <ul><li>A BDD framework to help with TDD and other TLAs </li></ul><ul><li>It’s Agile, Promotes Synergy, Enterprise, will shift Paradigms and completely Web 2.0 </li></ul><ul><li>You too can be BUZZ WORD compliant! </li></ul>
  22. 24. Img Source: http://www.themoreyouknow.com/
  23. 25. Natural Language @search Feature: Searching For Hello World, and some more overview of the feature that we are trying to test @google Scenario: User Searches for Hello World on Google.com Given I'm on Google's Home Page And I search for Hello World Then I should see Wikipedia's Hello World article as 1st result @bing Scenario: User Searches for Hello World on Bing.com Given I'm on Bing's Home Page And I search for Hello World Then I should see car videos as first result
  24. 26. Step Definitions Given /^I'm on Google's Home Page$/ do @selenium.open &quot; www.google.com &quot; end Given /^I'm on Bing's Home Page$/ do @selenium.open &quot; www.bing.com &quot; end When /^I search for Hello World$/ do @selenium.type &quot;q&quot;, &quot;Hello World&quot; end Then /^I should see Wikipedia's Hello World article as 1st result$/ do assert_stuff end Then /^I should see car videos as first result$/ do assert_stuff end
  25. 27. Why automated tests? <ul><li>Too expensive </li></ul><ul><li>Too much work to create </li></ul><ul><li>Not enough staff to maintain </li></ul><ul><li>Never know the coverage level </li></ul><ul><li>No one but developers knows what is being tested </li></ul>
  26. 28. Who should be writing tests?
  27. 29. Who should be writing tests? <ul><li>Developers </li></ul><ul><ul><li>Unit, Integration, Functional </li></ul></ul>
  28. 30. Who should be writing tests? <ul><li>Developers </li></ul><ul><ul><li>Unit, Integration, Functional </li></ul></ul><ul><li>QAs </li></ul><ul><ul><li>Functional, End-To-End </li></ul></ul>
  29. 31. Who should be writing tests? <ul><li>Developers </li></ul><ul><ul><li>Unit, Integration, Functional </li></ul></ul><ul><li>QAs </li></ul><ul><ul><li>Functional, End-To-End </li></ul></ul><ul><li>Everyone else </li></ul><ul><ul><li>At least the feature definitions </li></ul></ul>
  30. 32. Why automated tests? <ul><li>Too expensive </li></ul><ul><li>Too much work to create </li></ul><ul><li>Not enough staff to maintain </li></ul><ul><li>Never know the coverage level </li></ul><ul><li>No one but developers knows what is being tested </li></ul>
  31. 33. Mind Map Solution
  32. 34. Why automated tests? <ul><li>Too expensive </li></ul><ul><li>Too much work to create </li></ul><ul><li>Not enough staff to maintain </li></ul><ul><li>Never know the coverage level </li></ul><ul><li>No one but developers knows what is being tested </li></ul>
  33. 35. Good Features <ul><li>Tags </li></ul><ul><li>Encourages BDD/TDD </li></ul><ul><li>Supports multiple test drivers </li></ul><ul><li>Selenium 1 and Selenium 2 support </li></ul><ul><li>Multilingual </li></ul><ul><li>i18n support </li></ul><ul><li>Readable test results </li></ul>
  34. 36. Tags @search Feature: Searching For Hello World, and some more overview of the feature that we are trying to test @google @selenium Scenario: User Searches for Hello World on Google.com Given I'm on Google's Home Page And I search for Hello World Then I should see Wikipedia's Hello World article as 1st result @bing Scenario: User Searches for Hello World on Bing.com Given I'm on Bing's Home Page And I search for Hello World Then I should see car videos as first result
  35. 37. Tags @search Feature: Searching For Hello World, and some more overview of the feature that we are trying to test @google @selenium Scenario: User Searches for Hello World on Google.com Given I'm on Google's Home Page And I search for Hello World Then I should see Wikipedia's Hello World article as 1st result @bing Scenario: User Searches for Hello World on Bing.com Given I'm on Bing's Home Page And I search for Hello World Then I should see car videos as first result
  36. 38. Encourages BDD/TDD <ul><li>Write feature description first </li></ul><ul><li>Run test see it fail </li></ul><ul><li>Create one step definition at the time </li></ul><ul><li>Write functionality for the step </li></ul><ul><li>Run test see it pass </li></ul>
  37. 39. First run
  38. 40. First run
  39. 41. Write Step Definitions
  40. 42. Write More Step Definitions
  41. 43. Even More Step Definitions
  42. 44. Multiple Test Drivers Steam Celerity Culerity FireWatir SafariWatir ChromeWatir Img Source: Wikipedia
  43. 45. Selenium 1 support Before do | scenario | @selenium = Selenium::Client::Driver.new ( :host => &quot;localhost&quot;, :port => 4444, :browser => “firefox”, :url => “ www.google.com ”) end
  44. 46. Selenium 1 Tip Use Hpricot Or Nokogiri!!! page = Hpricot ( @selenium .get_html_source)
  45. 49. Selenium 2 support
  46. 50. Selenium 2 support <ul><li>Capybara + Selenium = Love </li></ul>
  47. 51. Selenium 2 support <ul><li>Capybara + Selenium = Love </li></ul><ul><li>Capybara + Selenium + Rails = ....... </li></ul>
  48. 52. Capybara <ul><li>Uses Nokogiri </li></ul><ul><li>Uses XPath outside of browser </li></ul><ul><li>Works outside of rails </li></ul>
  49. 53. Multilingual JVM: JRuby, Java .NET: IronRuby, IronRuby .NET, Mono Adoby Flex: FunFX, Melomel Python Erlang Groovy Scala Closure Javascript Spring
  50. 54. Java Step Definition package cukes; import cuke4duke.annotation.I18n.EN.Given; import java.util.List; import java.util.ArrayList; public class BellySteps { private List<String> belly = new ArrayList<String>(); @Given(&quot;I have (d+) cukes in my belly&quot;) public void bellyCukes(int cukes) { for(int i = 0; i < cukes; i++) { belly.add(&quot;cuke &quot; + i); } } }
  51. 55. i18n
  52. 56. i18n Функционал: Сложение чисел Чтобы не складывать в уме Все, у кого с этим туго Хотят автоматическое сложение целых чисел Сценарий: Сложение двух целых чисел Допустим я ввожу число 50 И затем ввожу число 70 Если я нажимаю &quot;+&quot; То результатом должно быть число 120
  53. 57. i18n Chinese 功能 : 加法 為了避免愚蠢的錯誤 作為一個數學白痴 我希望有人能告訴我兩個數相加的結果 場景大綱 : 將兩個數相加 假 設我已經在計算機上輸入 < 數值 _1> 而 且我已經在計算機上輸入 < 數值 _2> 當 我按下 < 按鈕 > 那 麼螢幕上應該顯示 < 結果 >
  54. 58. i18n LOLz OH HAI: STUFFING MISHUN: CUCUMBR I CAN HAZ IN TEH BEGINNIN 3 CUCUMBRZ WEN I EAT 2 CUCUMBRZ DEN I HAS 2 CUCUMBERZ IN MAH BELLY AN IN TEH END 1 CUCUMBRZ KTHXBAI
  55. 59. Readable Test Results
  56. 60. Bad Features <ul><li>Regex step definitions </li></ul><ul><li>Hard To find Step Definitions </li></ul><ul><li>Slower </li></ul><ul><li>Natural language parser </li></ul><ul><li>Messy directory structure </li></ul>
  57. 61. Regex Step Definitions <ul><li>Good: Reuse Definitions </li></ul><ul><li>Bad: </li></ul><ul><li>Then /^(?:|I )should see &quot;([^&quot;]*)&quot;(?: within &quot;([^&quot;]*)&quot;)?$/ do </li></ul>
  58. 62. Hard to find Step Definitions cucumber-tmbundle Vim Rails
  59. 63. Bad Features <ul><li>Regex step definitions </li></ul><ul><li>Hard To find Step Definitions </li></ul><ul><li>Slower </li></ul><ul><li>Natural language parser </li></ul><ul><li>Messy directory structure </li></ul>
  60. 64. Conclusion <ul><li>Cucumber is a great tool to </li></ul><ul><ul><li>Describe Features </li></ul></ul><ul><ul><li>Document Features </li></ul></ul><ul><ul><li>Get the whole team involved </li></ul></ul><ul><li>However, it has downsides also </li></ul>
  61. 65. @dhh RSpec offends me aesthetically with no discernible benefit for its added complexity over test/unit.
  62. 66. @dhh RSpec offends me aesthetically with no discernible benefit for its added complexity over test/unit. Cucumber makes no sense to me unless you have clients reading the tests. Why would you build a test-specific parser for English?
  63. 67. @dhh RSpec offends me aesthetically with no discernible benefit for its added complexity over test/unit. Cucumber makes no sense to me unless you have clients reading the tests. Why would you build a test-specific parser for English? The important thing is of course that we get people testing, so tools shouldn't matter too much....
  64. 68. Work @ Groupon www.groupon.com/techjobs
  65. 69. The End

×