don't you trust me?

Post on 20-May-2015

747 Views

Category:

Technology

2 Downloads

Preview:

Click to see full reader

DESCRIPTION

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.

TRANSCRIPT

Don’t you trust me?Seb Rose@sebrose

www.claysnow.co.uk

Business Driven Development

Beard Driven Development

Behaviour Driven Development

Easy transport of groceries

In order to get groceries home easily

Matt & Anna want

a way to transport them

Scenario: A month of groceries

Given I have opened the trunk When I load a month of groceries Then the suspension will cope

Scenario: A month of groceries

Given I have opened the trunk When I load a month of groceries Then the suspension will cope

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"

Given I have opened the trunk

@Given(“^I have opened the trunk$”)public void i_have_opened_the_trunk() { myCar.openTrunk();}

So, what exactly IS the problem?

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

@Given("I enter a new destination")public void I_enter_a_new_destination() { // Do whatever it takes to enter new destination}

• What if there is no GPS signal?

• What if the destination provided is unknown?

• How will errors be communicated to the user?

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

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" |

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

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”

@without_uiScenario: 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”

private boolean without_ui = false;

@Before("@without_ui") public void beforeScenario() { without_ui = true; }

@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. } }

•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

Service manual

Seb  Rose

Twi$er:     @sebrose

Blog:       www.claysnow.co.uk

E-­‐mail:     seb@claysnow.co.uk

Please evaluate my presentation at:www.touchmyconference.com/ATD2013

-JVM

Seb Rose,

Availa

ble 20

14

(hopef

ully)

top related