Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Cucumber: Best practices, troubles and ideas

Cucumber: Best practices, troubles and ideas

Roberto Zen

March 13, 2015
Tweet

More Decks by Roberto Zen

Other Decks in Technology

Transcript

  1. “Roberto, I need a test case that checks if there

    is a user in the db”. Specification
  2. User.count should be equal to 1 User.count should not be

    equal to 0 User.count should be greater than 0 Zenzu’s Task /^there exists a user$/
  3. “Roberto, I need a test case that checks if there

    is only one user in the db”. Specification
  4. Given there exists one user Given /^there exists one user$/

    do
 expect(User.count).to be_eq 1 end Test case
  5. “Roberto, I need another test case that checks if there

    are two users in the db”. Specification
  6. Given there exists 1 user Given there exists 2 users

    : Given there exists N users /^there exists (\d) users?$/ Smart enough
  7. Given there exist “[email protected]” who lives in Trento and “[email protected]

    who lives in Rome Given there exist “[email protected]” and “[email protected]” who live in Trento Given the following users exist: | email | role | city | [email protected] | peer | Trento | [email protected] | peer | Rome Given there exist “[email protected]” who lives in Trento
  8. “Roberto, did you already write a test definition which …?”.

    Let me check.. “Did I already write a test definition which …?”.
  9. Specifications Test cases Write test cases Now - Ideal Write

    step definitions }Whole team { (generalization)
 Zenzu’s task
  10. Specifications Test cases Write test cases Now - Ideal Write

    step definitions }Whole team documentation
  11. Given there exist :email who lives in :city and :email

    who lives in :city Given there exists :number :role btf metalanguage Given there exist an organization named :name with :number :role Given there exists 4 peers Given there exists 2 collectors
 
 Given there exists an organization named "Banco alimentare" with 4 peers Given there exists an organization named "Banco alimentare" with 4 collectors Given there exists an organization named "Banco alimentare" with 1 manager