• No results found

Test driven development (Koskela)

N/A
N/A
Protected

Academic year: 2021

Share "Test driven development (Koskela)"

Copied!
19
0
0

Loading.... (view fulltext now)

Full text

(1)

Test driven development (Koskela)

Chapter 9: Acceptance TDD Explained

Brittany Johnson

SWE 437

(2)

Overview

“In the spacecraft business no design can survive

the review process without first answering the

question—how are we going to test this thing?”

—Glen Alleman

User stories

From user stories to acceptance tests

The overall process

(3)

Format of a story

- free form

- or structured: As a (role) I want (functionality) so that (benefit) - often written on index cards

Card, conversation, confirmation (CCC)

Power of storytelling

- User view of what is needed, but now how it is provided

A user story

represents

a requirement, and creates a

promise

to

communicate with the customer later

“Storytelling reveals meaning without defining it”

– Hannah Arendt

(4)

Example user stories

4

Support technician sees

customer’s history

on-screen at the start of a call

Application authenticates

with the HTTP proxy

server

The system prevents user

from running multiple

instances of the application

simultaneously

State what,

NOT

how

Enabling value

: A user story is

valuable

because it

(5)

Create tests based on user stories

Properties of acceptance tests

- Owned by customer

- Written together with the customer, developer, and tester - Focus on the what, not the how

- Expressed in language of the problem domain – user’s vocabulary - Concise, precise, and unambiguous

In-class discussion

-

Consider the 3 user stories on previous slide (pg. 326)

-

Discuss whether and how they satisfy these properties

9.2 Acceptance Tests

(6)

Acceptance tests – example tests

6

Support technician sees customer’s

history on-screen at the start of a call

- Simulate a call with Fred’s account number and verify that

Fred’s info can be read from the screen

- Verify that the system displays a valid error message for

non-existing account number

- Omit the account number in the incoming call completely

and verify that the system displays the text “no account

number provided” on the screen

Fig. 9.1

(7)

Acceptance tests – what vs. how

7

1.

Go to the “new transaction” screen, fill in the required

details, and save the entry; verify that the transaction

shows up on the list

2. Select the “delete” checkbox for the newly created entry,

click “delete all marked transactions,” and verify they’re all

gone

3. Create multiple transactions, check several of them and

delete; verify that all selected transactions were indeed

deleted

Fig. 9.3

In-class discussion:

What is wrong with these tests?

- Too much HOW for users - Not in users’ vocabulary

Trimmed to focus on WHAT

Fig. 9.4 1. Try creating new order

2. Try deleting an order

(8)

Acceptance tests – what vs. how

8

Support technician sees customer’s

history on-screen at the start of a call

- Simulate a call with Fred’s account number and verify that

Fred’s info can be read from the screen

- Verify that the system displays a valid error message for

non-existing account number

- Omit the account number in the incoming call completely

and verify that the system displays the text “no account

number provided” on the screen

Fig. 9.1 Fig. 9.2

Too detailed

Trimmed version of tests

Fig. 9.5 1. Valid account number

2. Non-existing account number 3. No account number provided

(9)

The acceptance TDD cycle

1. Pick a story

2. Write tests for the story 3. Automate the tests

4. Implement the functionality

9.3 Understanding the process

Pick a user story Write tests Automate tests Implement

(10)

The acceptance TDD cycle

1. Pick a story (which story?)

- Most important - Business value - Technical risk

- Amount of programming 2. Write tests for the story 3. Automate the tests

4. Implement the functionality

A TDD Process – Step 1

(11)

The acceptance TDD cycle

1. Pick a story

2. Write tests for the story - Involve the customer - Iterate

- Keep abstract as long as possible - Get ahead of refactoring

3. Automate the tests

4. Implement the functionality

(12)

The acceptance TDD cycle

1. Pick a story

2. Write tests for the story 3. Automate the tests

- Start with a table format

- Translate to implementation/ - Postpone use of tools – tools steal focus from the topic

4. Implement the functionality

A TDD Process – Step 3

12

Action

Parameters

Place call

555-1234, account 123456

Accept call

555-1234

Verify text

123456

Verify text

Cory Customer

(13)

The acceptance TDD cycle

1. Pick a story

2. Write tests for the story 3. Automate the tests

4. Implement the functionality - This is done using TDD

- Each A-TDD test leads to multiple small tests

- As we get small tests to pass, we’re closer to A-test passing

(14)

Acceptance tests in agile methods

14 Acceptance test fails User story TDD test Add functionality Acceptance test passes Refactor Refactor

Customer must

approve

acceptance test

passing

(15)

In-class exercise

Customer orders

lunch at a kiosk

Write two or three acceptance tests for the following user story

Follow the guidelines in Chapter 9

(16)

Defining the customer role

- Representative of end users - Possible several people

Characteristics of customer role

- Shared interest in success - Authority to make decisions

- Ability to understand implications - Ability to explain domain

Key is to verify against target domain

9.4 Acceptance testing as a team activity

(17)

Who writes tests with the customer?

- Tester?

- Developer?

- Requirements expert? - Everybody?

How many testers do we need?

- One or two developers per tester - Tester is a role, not a job title

- All developers should be testers

More contributors is better

(18)

Definition of “done”

- Customer must agree it’s done - Knowing where we are

- Knowing when to stop - Test criteria satisfied

Cooperative work

Trust and commitment

Specification by example

- This is a big one!

Filling the gap

- Unit tests are not the same as acceptance tests

Both unit and acceptance tests are needed!

9.5 Benefits of acceptance testing

(19)

Should we test against the UI?

- Do whatever is easier long term - UIs are often in the way

- Good tools can automate tests through and around the UI - Performance might matter

Should we stub our system?

- Sufficiently close to the real thing - Sometimes stubs are necessary

Should we test business logic directly?

- Of course – it’s what the customer cares about

Tests are like votes –

they need to run early and often

Figure

Fig. 9.51.Valid account number

References

Related documents

Our method was to examine the associ- ation between student achievement and student-reported measures of instructional prac- tices in four waves (2003, 2007, 2011, and 2015) of

These strategies include (1) problematising tasks by inserting obstacles to the solution, limiting problem information or requiring students to use particular representations

A case study with 15 conventional units and 3 wind farms along with a fixed-sized PEV fleet demonstrates that shifting of PEV fleets charging at times of high wind availability

ACE-04G-LIC Application Control Engine (ACE) 4Gbps License 2 ACE-VIRT-050 Application Control Engine Virtualization 50 Contexts 2 WS-X6708-10G-3CXL C6K 8 port 10 Gigabit Ethernet

In an attempt to clearly identify the corrosion impact on the carbon steel surface, a blank carbon steel specimen (prior to corrosion experiment) was first analyzed then used as

The plenary indulgence is granted to the faithful under the usual conditions (sacramental Confession, Eucharistic Communion, and prayer for the Pope’s intentions) to Christians

Keywords: Asynchronous Learning, Auto-generated Content, Collaborative Learning, Corporate Sector Training, Lifelong Learning, e-Learning Concept, Education Sector

When a company recognises a material goodwill impairment loss, disclosure of information with regard to six or seven items in our index is triggered (depending on whether