T12
Concurrent Class
10/3/2013 11:15:00 AM

"Tests and Requirements: Like
Ham and Eggs, Sugar and Spice,
Lucy and Desi"
Pr...
Ken Pugh
Net Objectives
A fellow consultant with Net Objectives, Ken Pugh helps companies transform into lean-agile
organi...
9/19/2013

info@netobjectives.com
www.netobjectives.com

Tests and
Requirements:
You Can’t Have
One without the
Other
Ken ...
9/19/2013

Objectives
Show how requirements and tests are complementary
facets
How to create requirements and tests collab...
9/19/2013

Fast Car
Who wants a fast car?

5

Copyright © 2007 Net Objectives. All Rights Reserved.

19 September 2013

Re...
9/19/2013

Requirement Definition
Requirement is:
– Condition or capability needed by user to solve problem or
achieve obj...
9/19/2013

An Brownie Specification - MIL-C-44072C (1)
3.3.1 Brownie formula. The formula for the brownie shall be as
foll...
9/19/2013

Characteristics of Requirements
These characteristics often applied to requirements.
Bold indicates characteris...
9/19/2013

Software
Development

13

19 September 2013

The Team
Customer Unit - develops the requirements
–
–
–
–

Produc...
9/19/2013

Value Stream Map – Classical Development

Elicit Requirements

Code

Analyze
Requirements

Test

Design

Deploy...
9/19/2013

Value Stream Map – Agile Development

Elicit Requirements

Analyze
Requirements With
Tests

Code With Tests

17...
9/19/2013

Steps
Author the tests (write)
– Customer, tester, developer together

Connect tests to system (bind)
– Develop...
9/19/2013

A Better Way

write

bind

Code
run

21

Copyright © 2007 Net Objectives. All Rights Reserved.

19 September 20...
9/19/2013

Another Look at Testing Strategies
Focus of the tests (not exclusive)

Customer Tests

Exploratory Testing

Exp...
9/19/2013

Acceptance Testing

UI
Acceptance
Tests

Application /
Middle tier

Core Business Logic

Persistence

25

Copyr...
9/19/2013

Definitions
Acceptance criteria
– A statement of how something will be tested

Acceptance test outline
– Steps ...
9/19/2013

ATDD as a Prism

Requirements

29

ATDD

Copyright © 2007 Net Objectives. All Rights Reserved.

19 September 20...
9/19/2013

A First Example

31

19 September 2013

First Example
As a user, I want to convert a temperature in Fahrenheit ...
9/19/2013

Acceptance Test Outline
Given:
– A temperature in Fahrenheit

When
– The user converts it

Then
– The result sh...
9/19/2013

Stories

35

19 September 2013

Context
Sam’s Lawn Mower Repair and CD Rental Store
– A custom software package...
9/19/2013

User Story Examples

As the clerk, I want to check out a CD for a
customer.
As the clerk, I want to check in a ...
9/19/2013

Developable Stories
To become developable, stories require
– More detailed requirements
Workflow or use cases
P...
9/19/2013

Use Case Template – Part One
Name—Identifier to easily reference it by
Description—Brief note
Actor—Who initiat...
9/19/2013

Use Case Template – Part Two

Alternatives: flow that allows the use case to be
successful even if some conditi...
9/19/2013

Acceptance Tests

List of Acceptance Tests
– Rent a CD—This is the main course.
– Bad Customer ID—Enter the cus...
9/19/2013

Test Flow
Test

Setup
(Given))

Trigger
(When)

Assert
(Then)
Expected
System
State and
Output

Initial

Action...
9/19/2013

Acceptance Test
Using Tables

49

19 September 2013

Table Types
Calculation Table
Action Table
Data Table

50
...
9/19/2013

Calculation Table

Title
Input Name 1

Input Name 2

Result Name?

Notes

Anything that
Value for input 1 Value...
9/19/2013

Data Table
Exists (or should exist) – for Given and Then
Title Data
Value Name 1

Value Name 2

Value for 1

Va...
9/19/2013

Action Table
Enter enters data into an entry field
Press initiates a process, such as a Submit button on a
dial...
9/19/2013

Full
Requirements
and Tests

57

19 September 2013

Given / When / Then Example Outline
Given (Setup)
Customer ...
9/19/2013

Full Test
Check Out CD
Given Customer has ID
and CD has ID
and CD is not currently rented
Customer Data
Name

I...
9/19/2013

Full Test (3)
Then the CD is recorded as rented and a rental contract
is printed:
CD Data
ID

Title

Rented

Cu...
9/19/2013

Full Test - Exception
Check Out CD with CD Rental Limit
Given Customer has ID and CD has ID
and the Customer ha...
9/19/2013

The Other Tests
To be developable
– All tests should be complete
You are going to need them all anyway
The test...
9/19/2013

Iteration Based
Make Developable

Iteration
Backlog

Product
Backlog

Acceptance
Tests (or
Outline)

Acceptance...
9/19/2013

Iteration-less (Kanban)

Idea
Queue

Idea

69

Prioritize

Ready to Analyze
Analyze

Ready to Create
Detail
acc...
9/19/2013

Outlines
Objectives were:
– Show how requirements and tests are complementary facets
– How to create requiremen...
9/19/2013

Why Acceptance Tests?
Rework Down from 60% to 20%
Workflows Working First Time
Little Room for Miscommunication...
9/19/2013

Thank you.
Please fill out the evaluations

75

Copyright © 2007 Net Objectives. All Rights Reserved.

19 Septe...
9/19/2013

The Story
As a computer user, I want to copy a file from one
directory to another.
What’s your estimate?

77

C...
9/19/2013

Exercise
Write tests for:
“copying a file from one directory to another”
Describe in terms of:
– Given: some st...
9/19/2013

Copy File Example
Copy a file (happy path)
Given a source
and target directory

File system
Directory Name

Dir...
9/19/2013

Implementing
Acceptance Tests

83

19 September 2013

A Business Rule Example
If Customer Rating is Good and th...
9/19/2013

Business Rule Table = Test

Discount
Order total

Customer rating

Discount percentage?

$10.00

Good

0%

$10....
9/19/2013

Testing script
Tester creates script (usually GUI based).
Example:
–
–
–
–
–

Logon as Customer who is rated Go...
9/19/2013

XUnit Test
class TestCase {
testDiscountPercentageForCustomer() {
SomeClass o = new SomeClass()
assertEquals(0,...
9/19/2013

Example
Contributions
With States

91

19 September 2013

Retirement Contribution Example
Requirement
The syste...
9/19/2013

Given (Setup)
PlanID = XYZ
Name

Fund

George

WildEyedStocks

Sam

GovernmentBonds

Bill

UnderTheMattress

Pl...
9/19/2013

Then (Expected)

Expected Output
Funding

PlanID = XYZ

Name

Fund

Amount

George
Sam

WildEyedStocks
Governme...
9/19/2013

State Transitions
Contribution State Event
Initial
Received
data
Received
Data check is
bad
Received
Data check...
9/19/2013

info@netobjectives.com
www.netobjectives.com

A Few Problems

99

Copyright © 2007 Net Objectives. All Rights R...
9/19/2013

Another Hotel Display (1)

101

Copyright © 2007 Net Objectives. All Rights Reserved.

19 September 2013

Anoth...
Upcoming SlideShare
Loading in …5
×

Tests and Requirements: Like Ham and Eggs, Sugar and Spice, Lucy and Desi

238
-1

Published on

The practice of agile software development requires a clear understanding of business needs. Misunderstanding requirements causes waste, slipped schedules, and mistrust within the organization. Developers implement their perceived interpretation of requirements; testers test against their perceptions. Disagreement can arise about implementation defects, when the cause is really a disagreement about the requirement. Ken Pugh shows how acceptance tests decrease requirements misunderstandings by both developers and testers. A testable requirement provides a single source that serves as the analysis document, acceptance criteria, regression test suite, and progress tracker for any given feature. Explore the creation, evaluation, and use of testable requirements by the business and developers. Join Ken to examine how to transform requirements into stories, small units of work that have business value, small implementation effort, and easy-to-understand acceptance tests. Learn how testers and requirement elicitors can work together to create acceptance tests prior to implementation.

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
238
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
2
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Tests and Requirements: Like Ham and Eggs, Sugar and Spice, Lucy and Desi

  1. 1. T12 Concurrent Class 10/3/2013 11:15:00 AM "Tests and Requirements: Like Ham and Eggs, Sugar and Spice, Lucy and Desi" Presented by: Ken Pugh Net Objectives Brought to you by: 340 Corporate Way, Suite 300, Orange Park, FL 32073 888-268-8770 ∙ 904-278-0524 ∙ sqeinfo@sqe.com ∙ www.sqe.com
  2. 2. Ken Pugh Net Objectives A fellow consultant with Net Objectives, Ken Pugh helps companies transform into lean-agile organizations through training and coaching. His special interests are in communication (particularly effectively communicating requirements), delivering business value, and using lean principles to deliver high quality quickly. Ken trains, mentors, and testifies on technology topics from object-oriented design to Linux/Unix.
  3. 3. 9/19/2013 info@netobjectives.com www.netobjectives.com Tests and Requirements: You Can’t Have One without the Other Ken Pugh Fellow Consultant Net Objectives 1 Copyright © 2007 Net Objectives. All Rights Reserved. 19 September 2013 Ken Pugh Fellow Consultant Photo Size: Height: 2.25 Position: from top left corner Horizontal 0.75 Vertical 1. Picture Style: Simple Black Frame OOA&D, Design Patterns, Lean, Agile, Test-Driven Development Over 2/5 century of software development experience Author of seven books, including: ken.pugh @netobjectives.com – Prefactoring: Extreme Abstraction, Extreme Separation, Extreme Readability (2006 Jolt Award) – Interface Oriented Design – Lean Agile Acceptance Test-Driven Development: Better Software Through Collaboration No code goes in till the test goes on. A journey of two thousand miles begins with a single step. 2 Copyright © 2007 Net Objectives. All Rights Reserved. 19 September 2013 1
  4. 4. 9/19/2013 Objectives Show how requirements and tests are complementary facets How to create requirements and tests collaboratively 3 Copyright © 2007 Net Objectives. All Rights Reserved. 19 September 2013 Overall Rule There are exceptions to every statement, except this one 4 4 Copyright © 2007 Net Objectives. All Rights Reserved. 19 September 2013 2
  5. 5. 9/19/2013 Fast Car Who wants a fast car? 5 Copyright © 2007 Net Objectives. All Rights Reserved. 19 September 2013 Requirements 6 19 September 2013 3
  6. 6. 9/19/2013 Requirement Definition Requirement is: – Condition or capability needed by user to solve problem or achieve objective – Condition or capability met or possessed by system component to satisfy contract, standard, specification or regulation 7 7 Copyright © 2007 Net Objectives. All Rights Reserved. 19 September 2013 Requirements Requirements should include – Functions – what the software should do – Constraints – limitations on the manifestation Requirements should NOT include (usually) – Ways to implement the requirements – Specific manifestations – exactly what you want 8 8 Copyright © 2007 Net Objectives. All Rights Reserved. 19 September 2013 4
  7. 7. 9/19/2013 An Brownie Specification - MIL-C-44072C (1) 3.3.1 Brownie formula. The formula for the brownie shall be as follows: Ingredient Sugar 1/ Flour 2/ Shortening Nuts 3/ whole eggs 4/ 5/ Cocoa Dextrose, anhydrous Salt Parts by weight 23.0 21.0 16.8 16.0 13.0 5.5 4.4 .03 3/ U.S. Standards for Shelled English Walnuts (Fresh Products Branch, Fruit and Vegetable Division, Agricultural Marketing Service, U.S. Department of Agriculture) 9 Copyright © 2007 Net Objectives. All Rights Reserved. 19 September 2013 An Brownie Specification - MIL-C-44072C (2) 3.3.2 Brownie preparation. a. Whip eggs in large bowl on high speed until light and fluffy. b. Combine sugars, cocoa, salt, and leavening; add to beaten eggs, and whip on high speed until thick. c. Add shortening slowly while mixing on low speed. d. Scrape bowl and whip on high speed until thick. e. Mix flour, nuts, and flavors together and fold into batter; mix until uniform. f. Pour batter into pan at a rate that will yield uncoated brownies which, when cut such as to meet the dimension requirements specified in 3.4f, will weigh approximately 35 grams each. g. Bake at 3500F until done (30 to 45 minutes). 10 Copyright © 2007 Net Objectives. All Rights Reserved. 19 September 2013 5
  8. 8. 9/19/2013 Characteristics of Requirements These characteristics often applied to requirements. Bold indicates characteristics emphasized by agility Specific Unambiguous Testable/Verifiable Singular Design Independent Necessary Correct Consistent Complete Documented Prioritized Modifiable 11 11 Copyright © 2007 Net Objectives. All Rights Reserved. 19 September 2013 Question How do you know a requirement is testable? 12 Copyright © 2007 Net Objectives. All Rights Reserved. 19 September 2013 6
  9. 9. 9/19/2013 Software Development 13 19 September 2013 The Team Customer Unit - develops the requirements – – – – Product Owner Business analysts Users Quality Assurance Developer / Tester Unit – develops the implementation – Programmers – Testers / Quality Assurance The Triad – Customer, developer, tester 14 Copyright © 2007 Net Objectives. All Rights Reserved. 19 September 2013 7
  10. 10. 9/19/2013 Value Stream Map – Classical Development Elicit Requirements Code Analyze Requirements Test Design Deploy Why go back? 15 Copyright © 2007 Net Objectives. All Rights Reserved. 19 September 2013 Why Mistakes? Misunderstandings, missed requirements, mis-other Feedback helps to correct misunderstandings Quick feedback better than slow feedback Desired 16 Actual Copyright © 2007 Net Objectives. All Rights Reserved. Actual 19 September 2013 8
  11. 11. 9/19/2013 Value Stream Map – Agile Development Elicit Requirements Analyze Requirements With Tests Code With Tests 17 Design Deploy Copyright © 2007 Net Objectives. All Rights Reserved. 19 September 2013 Move Testing Forward Two types of testing Attempting to find defects – is WASTE Attempting to prevent defects – is ESSENTIAL When are defects found? – Prevention is just early detection 18 Copyright © 2007 Net Objectives. All Rights Reserved. 19 September 2013 9
  12. 12. 9/19/2013 Steps Author the tests (write) – Customer, tester, developer together Connect tests to system (bind) – Developer unit Run the tests (run) – Developers, testers, customers – Automated – part of build Test 19 write run bind Copyright © 2007 Net Objectives. All Rights Reserved. 19 September 2013 Usually the Case write Code 20 bind run Copyright © 2007 Net Objectives. All Rights Reserved. 19 September 2013 10
  13. 13. 9/19/2013 A Better Way write bind Code run 21 Copyright © 2007 Net Objectives. All Rights Reserved. 19 September 2013 Testing Strategies Meszaros, XUNIT TEST PATTERNS: REFACTORING TEST CODE, Fig 6.1 "Purpose of Tests" p. 51, © 2007 Pearson Education, Inc 22 Copyright © 2007 Net Objectives. All Rights Reserved. 19 September 2013 11
  14. 14. 9/19/2013 Another Look at Testing Strategies Focus of the tests (not exclusive) Customer Tests Exploratory Testing Expected Results Unexpected Results Valid Input Specified effects Unspecified effects Invalid input Specified error message Any side effects 23 Copyright © 2007 Net Objectives. All Rights Reserved. 19 September 2013 Verification and Validation Verification – Have we got the requirements right? – Focus of acceptance tests Validation – Have we got the right requirements? Customer really does it this way Environment is what we believe it to be – How do you test this? 24 Copyright © 2007 Net Objectives. All Rights Reserved. 19 September 2013 12
  15. 15. 9/19/2013 Acceptance Testing UI Acceptance Tests Application / Middle tier Core Business Logic Persistence 25 Copyright © 2007 Net Objectives. All Rights Reserved. 19 September 2013 Tests all the way down Test Test Test Requirement Requirement Customer Acceptance Tests Requirement Requires services to implement Test Service Implementation 26 Test Service Implementation Copyright © 2007 Net Objectives. All Rights Reserved. Developer Acceptance Tests 19 September 2013 13
  16. 16. 9/19/2013 Definitions Acceptance criteria – A statement of how something will be tested Acceptance test outline – Steps in an acceptance test Acceptance test – A test with all information for clear pass/fail repeatability 27 Copyright © 2007 Net Objectives. All Rights Reserved. 19 September 2013 Requirements and Tests Requirements and tests are inter-related – You can’t have one without the other Failing test is a requirement – Passing test denotes specification on how system works 28 Copyright © 2007 Net Objectives. All Rights Reserved. 19 September 2013 14
  17. 17. 9/19/2013 ATDD as a Prism Requirements 29 ATDD Copyright © 2007 Net Objectives. All Rights Reserved. 19 September 2013 Acceptance Test Examples 30 19 September 2013 15
  18. 18. 9/19/2013 A First Example 31 19 September 2013 First Example As a user, I want to convert a temperature in Fahrenheit to a temperature in Celsius. What is an acceptance criteria for this? What’s your estimate? 32 Copyright © 2007 Net Objectives. All Rights Reserved. 19 September 2013 16
  19. 19. 9/19/2013 Acceptance Test Outline Given: – A temperature in Fahrenheit When – The user converts it Then – The result should be the corresponding temperature in Celsius Exercise: What specific tests should there be? 33 Copyright © 2007 Net Objectives. All Rights Reserved. 19 September 2013 Acceptance Tests Fahrenheit (Input) 32 0 212 100 -459.7 -273.15 Precision Error -273.151 Below 0 Kelvin 1000 34 Celsius (Output) Notes 550 Maximum – Needed? Copyright © 2007 Net Objectives. All Rights Reserved. 19 September 2013 17
  20. 20. 9/19/2013 Stories 35 19 September 2013 Context Sam’s Lawn Mower Repair and CD Rental Store – A custom software package for CD rentals. 36 Copyright © 2007 Net Objectives. All Rights Reserved. 19 September 2013 18
  21. 21. 9/19/2013 User Story Examples As the clerk, I want to check out a CD for a customer. As the clerk, I want to check in a CD for a customer. As the inventory maintainer, I want to know where every CD is—in the store or rented. As the finance manager, I want to submit a credit card charge every time a CD is rented so that the store does not have to handle cash. 37 37 Copyright © 2007 Net Objectives. All Rights Reserved. 19 September 2013 Story Acceptance Criteria Check Out CD – Check out a CD. Check to see that it is recorded as rented. Check In CD – Check in a CD. Check to see that it is recorded as returned. – Check in a CD that is late. Check to see that it is noted as late. Report Inventory – Check out a few CDs. See if the report shows them as rented. – Check in a few CDs. See if the report shows them as in the store. Charge Rental – Check in a CD. See if the rental charge is correct. See if the credit charge matches the rental charge. See if the charge is made to the credit card company. Check that the bank account receives money from the charge. 38 Copyright © 2007 Net Objectives. All Rights Reserved. 19 September 2013 19
  22. 22. 9/19/2013 Developable Stories To become developable, stories require – More detailed requirements Workflow or use cases Possibly mock-up user interfaces – Acceptance test outline against those details 39 39 Copyright © 2007 Net Objectives. All Rights Reserved. 19 September 2013 Detailing Stories Use Cases Event / Response Tables (if there’s time) 40 Copyright © 2007 Net Objectives. All Rights Reserved. 19 September 2013 20
  23. 23. 9/19/2013 Use Case Template – Part One Name—Identifier to easily reference it by Description—Brief note Actor—Who initiates the use case Pre-conditions—What must be true before the use case is initiated Post-conditions—What is true if the use case successfully executes Main course—Steps that show the sequence of interactions 41 41 Copyright © 2007 Net Objectives. All Rights Reserved. 19 September 2013 Use Case Example – Part One Name—Check Out CD. Description—Check out a CD for a customer. Actor—Clerk. Pre-conditions—The customer has an identification. The CD has an identity. Post-conditions—The CD is recorded as rented. The rental contract is printed. Main Course: 1. The clerk enters the customer identification and CD identifier into the system. 2. The system records the information. 3. The system prints a contract that the customer signs. 42 42 Copyright © 2007 Net Objectives. All Rights Reserved. 19 September 2013 21
  24. 24. 9/19/2013 Use Case Template – Part Two Alternatives: flow that allows the use case to be successful even if some condition occurs Exceptions: conditions can occur that may not allow it to reach its post-conditions. Business Rules: rules that must be followed regardless of technology Note: Alternatives and Exceptions could become separate story(ies) if requires significant effort Exceptions and Alternatives numbered with reference to Main Course steps 43 43 Copyright © 2007 Net Objectives. All Rights Reserved. 19 September 2013 Use Case Example – Part Two Exceptions: 1a. Customer identification is not recognized. Clerk repeats step 1. 1b. The customer violates the CD Rental Limit business rule. The clerk notifies the customer of the violation. The use case is abandoned. Business Rule: CD Rental Limit A customer can rent only three CDs at any one time. Alternatives 3a. The printer jams. The clerk fills out the contract by hand. The use case exits. 44 44 Copyright © 2007 Net Objectives. All Rights Reserved. 19 September 2013 22
  25. 25. 9/19/2013 Acceptance Tests List of Acceptance Tests – Rent a CD—This is the main course. – Bad Customer ID—Enter the customer ID wrong. – CD Rental Limit—A customer has three CDs and rents another one. – Printer Jam—Simulate a printer jam (maybe out of paper). 45 45 Copyright © 2007 Net Objectives. All Rights Reserved. 19 September 2013 Acceptance Test Outline 46 19 September 2013 23
  26. 26. 9/19/2013 Test Flow Test Setup (Given)) Trigger (When) Assert (Then) Expected System State and Output Initial Action or Event System State 47 Final System State and Output Copyright © 2007 Net Objectives. All Rights Reserved. 19 September 2013 Given / When / Then Outline Given (Setup) Customer has ID (initial system state) CD has ID (initial system state) CD is not currently rented (initial system state) When (Trigger) Clerk checks out CD (action) Then (Verify) CD recorded as rented (final system state) Rental contract printed (output) 48 Copyright © 2007 Net Objectives. All Rights Reserved. 19 September 2013 24
  27. 27. 9/19/2013 Acceptance Test Using Tables 49 19 September 2013 Table Types Calculation Table Action Table Data Table 50 Copyright © 2007 Net Objectives. All Rights Reserved. 19 September 2013 25
  28. 28. 9/19/2013 Calculation Table Title Input Name 1 Input Name 2 Result Name? Notes Anything that Value for input 1 Value for input 2 Expected output describes scenario Another value for input 1 Another value for input 2 51 Another expected output Copyright © 2007 Net Objectives. All Rights Reserved. 19 September 2013 Calculation Table Example Discount Calculation Item Total Customer Rating Discount Percentage? $10.00 Good When 0% Then Given 52 Copyright © 2007 Net Objectives. All Rights Reserved. 19 September 2013 26
  29. 29. 9/19/2013 Data Table Exists (or should exist) – for Given and Then Title Data Value Name 1 Value Name 2 Value for 1 Value for 2 Another value for 1 Another value for 2 53 Copyright © 2007 Net Objectives. All Rights Reserved. 19 September 2013 Data Table Example Customer Data Name James 007 Maxwell 54 ID 86 Copyright © 2007 Net Objectives. All Rights Reserved. 19 September 2013 27
  30. 30. 9/19/2013 Action Table Enter enters data into an entry field Press initiates a process, such as a Submit button on a dialog box Check sees if a result is equal to an expected value. Action Name Enter Value Name 1 Value for 1 Enter Value Name 2 Value for 2 Press Submit Check Value Name 3 55 Expected value for 3 Copyright © 2007 Net Objectives. All Rights Reserved. 19 September 2013 Action Table Example Can be just “When” or a stand-alone Given-When-Then Check Out CD Enter Customer ID 007 Enter CD ID CD2 When Press Rent Then Check Rented Given 56 True Copyright © 2007 Net Objectives. All Rights Reserved. 19 September 2013 28
  31. 31. 9/19/2013 Full Requirements and Tests 57 19 September 2013 Given / When / Then Example Outline Given (Setup) Customer has ID (initial system state) CD has ID (initial system state) CD is not currently rented (initial system state) When (Trigger) Clerk checks out CD (action) Then (Verify) CD recorded as rented (final system state) Rental contract printed (output) 58 Copyright © 2007 Net Objectives. All Rights Reserved. 19 September 2013 29
  32. 32. 9/19/2013 Full Test Check Out CD Given Customer has ID and CD has ID and CD is not currently rented Customer Data Name ID James 007 CD Data ID Title Rented CD2 Beatles Greatest Hits No 59 Copyright © 2007 Net Objectives. All Rights Reserved. 19 September 2013 Full Test (2) When a clerk checks out a CD: Check Out CD Enter 007 Enter CD ID CD2 Press 60 Customer ID Rent Copyright © 2007 Net Objectives. All Rights Reserved. 19 September 2013 30
  33. 33. 9/19/2013 Full Test (3) Then the CD is recorded as rented and a rental contract is printed: CD Data ID Title Rented Customer ID CD2 Beatles Greatest Hits Yes 007 Rental Contract Customer ID Customer Name CD ID CD Title 007 James CD2 Beatles Greatest Hits 61 Copyright © 2007 Net Objectives. All Rights Reserved. 19 September 2013 The Action Can drive a GUI Or a method Rent(CustomerID aCustomer, CDID, aCD); 62 Copyright © 2007 Net Objectives. All Rights Reserved. 19 September 2013 31
  34. 34. 9/19/2013 Full Test - Exception Check Out CD with CD Rental Limit Given Customer has ID and CD has ID and the Customer has three rentals already Customer Data Name ID James 007 CD Data ID Rented Customer ID CD2 Yes 007 CD3 Yes 007 CD4 Yes 007 CD5 No 63 Copyright © 2007 Net Objectives. All Rights Reserved. 19 September 2013 Full Test Exception (2) When a clerk checks out a CD Then CD Rental Limit occurs Check Out CD Enter 007 Enter CD ID CD5 Press Rent Check 64 Customer ID Status CD_Rental_Limit_Exceeded Copyright © 2007 Net Objectives. All Rights Reserved. 19 September 2013 32
  35. 35. 9/19/2013 The Other Tests To be developable – All tests should be complete You are going to need them all anyway The tests detail the requirement Pragmatically – Sufficient tests need to be complete – Defining “sufficient” is the hard part 65 Copyright © 2007 Net Objectives. All Rights Reserved. 19 September 2013 When To Write Story Tests 66 19 September 2013 33
  36. 36. 9/19/2013 Iteration Based Make Developable Iteration Backlog Product Backlog Acceptance Tests (or Outline) Acceptance Criteria 67 Copyright © 2007 Net Objectives. All Rights Reserved. 19 September 2013 Make Developable Within iteration write bind Code run Previous iteration write bind Code run 68 Copyright © 2007 Net Objectives. All Rights Reserved. 19 September 2013 34
  37. 37. 9/19/2013 Iteration-less (Kanban) Idea Queue Idea 69 Prioritize Ready to Analyze Analyze Ready to Create Detail acceptance tests Ready to Develop Develop Ready for “Release Set” testing Story Story Story Done Copyright © 2007 Net Objectives. All Rights Reserved. 19 September 2013 Not An Ending, But A Beginning 70 19 September 2013 35
  38. 38. 9/19/2013 Outlines Objectives were: – Show how requirements and tests are complementary facets – How to create requirements and tests collaboratively 71 Copyright © 2007 Net Objectives. All Rights Reserved. 19 September 2013 Other Things Tests Are Good For Acceptance tests can also be used as: – Estimation aid To break stories down if they are too big – Degree of doneness Percentage of passing acceptance tests is “rough” indication of story completion – Regression test suite particularly if automated 72 Copyright © 2007 Net Objectives. All Rights Reserved. 19 September 2013 36
  39. 39. 9/19/2013 Why Acceptance Tests? Rework Down from 60% to 20% Workflows Working First Time Little Room for Miscommunication Saving Time Getting Business Rules Right Game Changing Tighter Cross-Functional Team Integration Crisp Visible Story Completion Criteria Automation Yields Reduced Testing Time 73 Copyright © 2007 Net Objectives. All Rights Reserved. 19 September 2013 Now, if there’s time, an exercise If not: 74 Copyright © 2007 Net Objectives. All Rights Reserved. 19 September 2013 37
  40. 40. 9/19/2013 Thank you. Please fill out the evaluations 75 Copyright © 2007 Net Objectives. All Rights Reserved. 19 September 2013 An Exercise 76 19 September 2013 38
  41. 41. 9/19/2013 The Story As a computer user, I want to copy a file from one directory to another. What’s your estimate? 77 Copyright © 2007 Net Objectives. All Rights Reserved. 19 September 2013 The Interface GUI Command line CopyFile <SourceDirectory> <TargetDirectory> <Filename> 78 Copyright © 2007 Net Objectives. All Rights Reserved. 19 September 2013 39
  42. 42. 9/19/2013 Exercise Write tests for: “copying a file from one directory to another” Describe in terms of: – Given: some state – When: copy (file, source_directory, destination_directory) – Then: expected state When Given Source Directory Contents Destination Directory Contents Then (Expected) Copy File X X Destination Directory Contents? X 79 Anything else? Copyright © 2007 Net Objectives. All Rights Reserved. 19 September 2013 Copying Table Example Given Then (Expected) When Source Directory Contents Destination Directory Contents Copy File Destination Directory Contents? Source Directory Contents? Content Comparison? Notes X, Y, Z D,E,f X D,E,F,X X,Y,Z (Destination.X == Source.X) Standard copy X, Y, Z D,E,F,X X D,E,F,X X,Y,Z (Destination.X == Source.X) X overwritte n X, Y, Z D,E,F,X X D,E,F,X X,Y,Z (Destination.X == Destination.X) X not overwritte n What about modification date and other attributes? Make more columns 80 Copyright © 2007 Net Objectives. All Rights Reserved. 19 September 2013 40
  43. 43. 9/19/2013 Copy File Example Copy a file (happy path) Given a source and target directory File system Directory Name Directory Contents A X, Y, Z D,E,F B Copy File Enter Source Directory A Enter Target Directory B Enter File name X Press When copy request is made Copy File system Then file is copied Directory Name Directory Contents A X, Y, Z D,E,F,X B 81 Copyright © 2007 Net Objectives. All Rights Reserved. 19 September 2013 Copy File Example Non-existent file Given a source and target directory File system Directory Name Directory Contents A X, Y, Z D,E,F B When copy request is made for a non-existent file , an error is generated Copy File Enter Source Directory A Enter Target Directory B Enter File name Q Press Copy Error_file_does_not_exist Anything else? 82 Copyright © 2007 Net Objectives. All Rights Reserved. 19 September 2013 41
  44. 44. 9/19/2013 Implementing Acceptance Tests 83 19 September 2013 A Business Rule Example If Customer Rating is Good and the Order Total is less than or equal $10.00, Then do not give a discount, Otherwise give a 1% discount. If Customer Rating is Excellent, Then give a discount of 1% for any order. If the Order Total is greater than $50.00, Then give a discount of 5%. 84 Copyright © 2007 Net Objectives. All Rights Reserved. 19 September 2013 42
  45. 45. 9/19/2013 Business Rule Table = Test Discount Order total Customer rating Discount percentage? $10.00 Good 0% $10.01 Good 1% $50.01 Good 1% $.01 Excellent 1% $50.00 Excellent 1% $50.01 Excellent 5% 85 Copyright © 2007 Net Objectives. All Rights Reserved. 19 September 2013 Ways To Implement Test Testing script Program interface Xunit framework ATDD framework 86 Copyright © 2007 Net Objectives. All Rights Reserved. 19 September 2013 43
  46. 46. 9/19/2013 Testing script Tester creates script (usually GUI based). Example: – – – – – Logon as Customer who is rated Good Start order Put items in the order until the total is exactly $10.01 Complete order Check it shows a $.10 discount Repeat for other five cases 87 Copyright © 2007 Net Objectives. All Rights Reserved. 19 September 2013 Program interface Create a command line or graphic user interface Discount Percentage Screen Screen Customer Type: Good Order Total: 10.01 Percentage: Discount Method 1 % C:>DiscountPercentage Good 10.01 Percentage: 1% 88 Copyright © 2007 Net Objectives. All Rights Reserved. 19 September 2013 44
  47. 47. 9/19/2013 XUnit Test class TestCase { testDiscountPercentageForCustomer() { SomeClass o = new SomeClass() assertEquals(0, o.computeDiscount(10.0, Good)); assertEquals(1, o.computeDiscount(10.01, Good)); assertEquals(1, o.computeDiscount(50.01, Good)); assertEquals(1, o.computeDiscount(.01, Excellent)); assertEquals(1, o.computeDiscount(50.0, Excellent)); assertEquals(5, o.computeDiscount(50.01, Excellent)); } } 89 Copyright © 2007 Net Objectives. All Rights Reserved. 19 September 2013 Fit (Table = Test) Discount Order total Discount percentage? 10.00 Good 0 10.01 Good 1 50.01 Good 1 .01 Excellent 1 50.00 Excellent 1 50.01 90 Customer rating Excellent 5 Copyright © 2007 Net Objectives. All Rights Reserved. 19 September 2013 45
  48. 48. 9/19/2013 Example Contributions With States 91 19 September 2013 Retirement Contribution Example Requirement The system shall match incoming retirement contribution files with bank deposits. If the total on the contribution files matches the bank deposit, the corresponding funds shall be purchased. Exceptions ? Retirement Plan Contribution File 92 Bank Deposit Process Funding Copyright © 2007 Net Objectives. All Rights Reserved. 19 September 2013 46
  49. 49. 9/19/2013 Given (Setup) PlanID = XYZ Name Fund George WildEyedStocks Sam GovernmentBonds Bill UnderTheMattress PlanID Bank Routing Number Account Number XYZ 111-11-11111 12345678 93 Copyright © 2007 Net Objectives. All Rights Reserved. 19 September 2013 When (Trigger) File Received 401K Contributions PlanID=XYZ Name Amount George 5000 Sam 1000 Bill 500 Bank Deposit Routing Number Amount 111-11-11111 94 Account Number 12345678 6500 Copyright © 2007 Net Objectives. All Rights Reserved. 19 September 2013 47
  50. 50. 9/19/2013 Then (Expected) Expected Output Funding PlanID = XYZ Name Fund Amount George Sam WildEyedStocks GovernmentBonds 5000 1000 Bill UnderTheMattress 500 95 Copyright © 2007 Net Objectives. All Rights Reserved. 19 September 2013 Contribution States Contribution State Received Awaiting Match Purchase Funds Begin Exception Processing Edit Processing 96 Meaning Contribution File received Waiting for Bank Deposit Matched Bank Deposit, buy funds Bank Deposit received, but incorrect Contribution File bad format Copyright © 2007 Net Objectives. All Rights Reserved. 19 September 2013 48
  51. 51. 9/19/2013 State Transitions Contribution State Event Initial Received data Received Data check is bad Received Data check is good Awaiting Match Matched exactly Awaiting Match Discrepancy in match AwaitingMatch Matching time exceeded Purchase Funds One minute prior to market close 97 New State Received Notes EditProcessing Awaiting Match Purchase Funds Matching on entry and ½ hour before close BeginExceptionProcessing BeginExceptionProcessing Awaiting Confirmation Enter order for funds Copyright © 2007 Net Objectives. All Rights Reserved. 19 September 2013 Deposit States Deposit State Initial Received Received New State Received Edit Processing Awaiting Match Awaiting Match 98 Event Data received Data check is bad Data check is good MatchedExactly Matched Copyright © 2007 Net Objectives. All Rights Reserved. 19 September 2013 49
  52. 52. 9/19/2013 info@netobjectives.com www.netobjectives.com A Few Problems 99 Copyright © 2007 Net Objectives. All Rights Reserved. 19 September 2013 A Hotel Display 100 Copyright © 2007 Net Objectives. All Rights Reserved. 19 September 2013 50
  53. 53. 9/19/2013 Another Hotel Display (1) 101 Copyright © 2007 Net Objectives. All Rights Reserved. 19 September 2013 Another Hotel Display (2) 102 Copyright © 2007 Net Objectives. All Rights Reserved. 19 September 2013 51

×