In many organisations there’s a tension between the desires of the three amigos:
- business stakeholders can’t validate assumptions unless they’re written in business domain terms
- testers would ideally test everything end to end (vertically)
- developers respond that the testing pyramid encourages us to have more unit tests than integration or end-to-end tests
It is often recommended that some tests that start off as scenarios get pushed ‘down’ into unit tests to keep the execution time under control and constrain the maintenance burden of the feature suite. The trouble with this is that even if the business folk and the testers trusted the developer’s unit tests implicitly (which they often don’t) there’s still the issue of visibility. We no longer have one complete, generally consumable, source living documentation.
An approach that I have been experimenting with uses Cucumber’s tagged hooks to control the amount of application stack that a scenario exercises. This lets us tailor our execution context depending on the runtime of the feature suite and the amount of trust the team has to spare. In the limit, this allows us (where it makes sense) to expose some unit tests as scenarios – keeping our living documentation complete.
The cost, of course, is added complexity.
5. What’s
the difference
between TDD,
ATDD, BDD
and SbE?
They’re
called
different
things
http://lizkeogh.com/2011/06/27/atdd-vs-bdd-and-a-potted-history-of-some-related-stuff/
6. Easy transport of groceries
In order to get groceries home easily
Matt & Anna want
a way to transport them
7.
8.
9.
10.
11.
12.
13. Scenario: A month of groceries
Given I have opened the trunk
When I load a month of groceries
Then the suspension will cope
14. Scenario: A month of groceries
Given I have opened the trunk
When I load a month of groceries
Then the suspension will cope
15. Scenario: A year of groceries
Given I have opened the trunk
When I load a year of groceries
Then the suspension will cope
expected: "Within tolerance",
got: "OVERLOADED"
16. Given I have opened the trunk
@Given(“^I have opened the trunk$”)
public void i_have_opened_the_trunk() {
myCar.openTrunk();
}
26. Feature: GPS usage
Scenario: Start navigation to new destination
Given I enter a new destination
When I start navigation
Then I should be given first direction
27. @Given("I enter a new destination")
public void I_enter_a_new_destination() {
// Do whatever it takes to enter new destination
}
28. •
What if there is no GPS signal?
•
What if the destination provided is unknown?
•
How will errors be communicated to the user?
29. Scenario: No GPS signal
Given I enter a new destination
And it there is no GPS signal
When I start navigation
Then I should see the correct error message
Scenario: Unknown destination
Given I enter a new destination
And the destination is unknown
When I start navigation
Then I should see the correct error message
30. Scenario Outline: Display correct error message
When the navigation component returns an <error>
Then the correct <message> should be returned
Examples:
| error
| message
| no-gps-signal
| "No GPS signal"
| unknown-destination
| "Unknown destination"
|
|
|
31. Scenario: No GPS signal
Given I enter a new destination
And it there is no GPS signal
When I start navigation
Then I should see the no-gps-signal message
Scenario: Unknown destination
Given I enter a new destination
And the destination is unknown
When I start navigation
Then I should see the unknown-destination message
32. Scenario: No GPS signal
Given I enter a new destination
And it there is no GPS signal
When I start navigation
Then I should see “No GPS signal”
Scenario: Unknown destination
Given I enter a new destination
And the destination is unknown
When I start navigation
Then I should see “Unknown destination”
33. @without_ui
Scenario: No GPS signal
Given I enter a new destination
And it there is no GPS signal
When I start navigation
Then I should see “No GPS signal”
35. @Given("^I enter a new destination$")
public void I_enter_a_new_destination() {
if (without_ui){
// Call navigation component directly
} else {
// Drive UI directly using Selenium or similar.
}
}
36.
37.
38.
39. Service manual
•Exercise full application stack to
build trust
•Reduce thickness as trust grows
•A few end-to-end scenarios is
often all you need
•Keep living documentation
comprehensive
40. Please evaluate my presentation at:
www.touchmyconference.com/ATD2013
Seb
Rose
Twi$er:
@sebrose
Blog:
www.claysnow.co.uk
E-‐mail:
seb@claysnow.co.uk
-JVM
14
20
le y)
ab ll
il fu
va pe
A
ho
(
Seb Rose,