Slide 1

Slide 1 text

Best practices, troubles and ideas

Slide 2

Slide 2 text

omg a new logo Best practices, troubles and ideas

Slide 3

Slide 3 text

Outline - Step definition generalization - Test cases documentation - Different approach to BDD

Slide 4

Slide 4 text

Goals - Understand if a different approach might be useful - Advantages and disadvantages

Slide 5

Slide 5 text

Specifications Test cases Zenzu's task Some months ago

Slide 6

Slide 6 text

“Roberto, I need a test case that checks if there is a user in the db”. Specification

Slide 7

Slide 7 text

Given there exists a user Test case

Slide 8

Slide 8 text

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$/

Slide 9

Slide 9 text

“Roberto, I need a test case that checks if there is only one user in the db”. Specification

Slide 10

Slide 10 text

Given there exists one user Given /^there exists one user$/ do
 expect(User.count).to be_eq 1 end Test case

Slide 11

Slide 11 text

“Roberto, I need another test case that checks if there are two users in the db”. Specification

Slide 12

Slide 12 text

Given there exists 1 user Given there exists 2 users : Given there exists N users /^there exists (\d) users?$/ Smart enough

Slide 13

Slide 13 text

Specifications (not well defined) Test cases (not well defined) Zenzu's task problem

Slide 14

Slide 14 text

Given there exists “[email protected]

Slide 15

Slide 15 text

Given there exists “[email protected]

Slide 16

Slide 16 text

Given there exists “[email protected]” ?

Slide 17

Slide 17 text

Given there exists a peer with email “[email protected]

Slide 18

Slide 18 text

Given there exist “[email protected]” and “[email protected]

Slide 19

Slide 19 text

Given the following users exist: | email | role | | [email protected] | peer | | [email protected] | collector |

Slide 20

Slide 20 text

Given there exist “[email protected]” and “[email protected]” who live in Trento

Slide 21

Slide 21 text

Given there exist “[email protected]” who lives in Trento and “[email protected]” who lives in Rome

Slide 22

Slide 22 text

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

Slide 23

Slide 23 text

#1: What is the right level of generalization we need?

Slide 24

Slide 24 text

Specifications Test cases Write test cases Now Write step definitions }Whole team

Slide 25

Slide 25 text

“Roberto, did you already write a test definition which …?”. Let me check.. “Did I already write a test definition which …?”.

Slide 26

Slide 26 text

#2: Not a question. We need documentation.

Slide 27

Slide 27 text

What I usually do

Slide 28

Slide 28 text

https://github.com/burtlo/yard-cucumber

Slide 29

Slide 29 text

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

Slide 30

Slide 30 text

Specifications Test cases Write test cases Now - Ideal Write step definitions }Whole team documentation

Slide 31

Slide 31 text

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