avatars of tdd - agile india€¦ · avatars of tdd rule of diversity ... outside in inside out...
Post on 25-Jun-2020
19 Views
Preview:
TRANSCRIPT
Copyright © 2013, AgileFAQs. All Rights Reserved.
Avatars of TDDRule of Diversity
Distrust all claims for “One True Way”
Naresh Jainnaresh@agilefaqs.com
@nashjain http://nareshjain.com
1Saturday 2 March 2013
Copyright © 2013, AgileFAQs. All Rights Reserved.
Key Questions
Are we building the right product?
Are we building the product right?
Business Facing
Technology/Implementation Facing
2Saturday 2 March 2013
Copyright © 2013, AgileFAQs. All Rights Reserved.
Brian Marick’s Test Categorization
Business Facing
Technology/Implementation Facing
Supp
orts
Pro
gram
min
gC
ritique product
3Saturday 2 March 2013
Copyright © 2013, AgileFAQs. All Rights Reserved.
It Helps to Think of Tests this way...
Business Facing
Technology/Implementation Facing
Dri
ves
Dev
elop
men
t Critique product
4Saturday 2 March 2013
Copyright © 2013, AgileFAQs. All Rights Reserved.
It Helps to Think of Tests this way...
Business Facing
Technology/Implementation Facing
Dri
ves
Dev
elop
men
t Critique productUnit Testing
4Saturday 2 March 2013
Copyright © 2013, AgileFAQs. All Rights Reserved.
It Helps to Think of Tests this way...
Business Facing
Technology/Implementation Facing
Dri
ves
Dev
elop
men
t Critique productUnit Testing
Acceptance Testing Low-fi prototypes
4Saturday 2 March 2013
Copyright © 2013, AgileFAQs. All Rights Reserved.
It Helps to Think of Tests this way...
Business Facing
Technology/Implementation Facing
Dri
ves
Dev
elop
men
t Critique productUnit Testing
Acceptance Testing Low-fi prototypes
Exploratory TestingUI and Usability Testing
4Saturday 2 March 2013
Copyright © 2013, AgileFAQs. All Rights Reserved.
It Helps to Think of Tests this way...
Business Facing
Technology/Implementation Facing
Dri
ves
Dev
elop
men
t Critique productUnit Testing
Acceptance Testing Low-fi prototypes
Exploratory TestingUI and Usability Testing
Performance TestingSystem Tests
4Saturday 2 March 2013
Business Facing
Technology/Implementation Facing
Dri
ves
Dev
elop
men
t Critique product
Outside In
Inside Out
Brian Marick’s Test Categorization
5Saturday 2 March 2013
TDD RhythmTest, Code, Refactor
6Saturday 2 March 2013
Add a Test
TDD RhythmTest, Code, Refactor
6Saturday 2 March 2013
Add a Test
Run the Test
TDD RhythmTest, Code, Refactor
6Saturday 2 March 2013
Add a Test
Run the Test
Pass
TDD RhythmTest, Code, Refactor
6Saturday 2 March 2013
Add a Test
Run the Test
Fail
Pass
TDD RhythmTest, Code, Refactor
6Saturday 2 March 2013
Add a Test
Run the Test
Make a little change
Fail
Pass
TDD RhythmTest, Code, Refactor
6Saturday 2 March 2013
Add a Test
Run the Test
Make a little change
Run the Test
Fail
Pass
TDD RhythmTest, Code, Refactor
6Saturday 2 March 2013
Add a Test
Run the Test
Make a little change
Run the Test
Fail
Fail
Pass
TDD RhythmTest, Code, Refactor
6Saturday 2 March 2013
Add a Test
Run the Test
Make a little change
Run the Test
Fail
Pass
Fail
Pass
TDD RhythmTest, Code, Refactor
6Saturday 2 March 2013
Add a Test
Run the Test
Make a little change
Run the Test
Refactor
Fail
Pass
Fail
Pass
TDD RhythmTest, Code, Refactor
6Saturday 2 March 2013
Add a Test
Run the Test
Make a little change
Run the Test
Refactor
Fail
Pass
Fail
Pass
TDD RhythmTest, Code, Refactor
6Saturday 2 March 2013
Add a Test
Run the Test
Make a little change
Run the Test
Refactor
Fail
Pass
Fail
Pass
TDD RhythmTest, Code, Refactor
6Saturday 2 March 2013
Add a Test
Run the Test
Make a little change
Run the Test
Refactor
Fail
Pass
Fail
Pass
TDD RhythmTest, Code, Refactor
6Saturday 2 March 2013
Copyright © 2013, AgileFAQs. All Rights Reserved.
Acceptance Test Driven Development
7Saturday 2 March 2013
Copyright © 2013, AgileFAQs. All Rights Reserved.
Acceptance Test Driven Development
Story
7Saturday 2 March 2013
Copyright © 2013, AgileFAQs. All Rights Reserved.
Acceptance Test Driven Development
Story
Acceptance Criteria
7Saturday 2 March 2013
Copyright © 2013, AgileFAQs. All Rights Reserved.
Acceptance Test Driven Development
Iteration
Story
Acceptance Criteria
7Saturday 2 March 2013
Copyright © 2013, AgileFAQs. All Rights Reserved.
Acceptance Test Driven Development
Iteration
Automated Acceptance Tests
Story
Acceptance Criteria
7Saturday 2 March 2013
Copyright © 2013, AgileFAQs. All Rights Reserved.
Acceptance Test Driven Development
Iteration
Automated Acceptance Tests
Story
Acceptance Criteria
Automated Unit Test
7Saturday 2 March 2013
Copyright © 2013, AgileFAQs. All Rights Reserved.
Acceptance Test Driven Development
Iteration
Automated Acceptance Tests
AutomatedAcceptance Tests
Story
Acceptance Criteria
Automated Unit Test
7Saturday 2 March 2013
Copyright © 2013, AgileFAQs. All Rights Reserved.
Acceptance Test Driven Development
Iteration
Automated Acceptance Tests
AutomatedAcceptance Tests
Story
Acceptance Criteria
ExploratoryTesting
Automated Unit Test
7Saturday 2 March 2013
Copyright © 2013, AgileFAQs. All Rights Reserved.
Acceptance Test Driven Development
Iteration
Automated Acceptance Tests
AutomatedAcceptance Tests
Story
Acceptance Criteria
Acceptance Criteria
ExploratoryTesting
Automated Unit Test
7Saturday 2 March 2013
Copyright © 2013, AgileFAQs. All Rights Reserved.
Acceptance Test Driven Development
Iteration
Automated Acceptance Tests
AutomatedAcceptance Tests
Story
Acceptance Criteria
Acceptance Criteria
ExploratoryTesting
Automated UI Tests
Automated Unit Test
7Saturday 2 March 2013
Copyright © 2013, AgileFAQs. All Rights Reserved.
Acceptance Test Driven Development
Iteration
Automated Acceptance Tests
AutomatedAcceptance Tests
Story
Acceptance Criteria
Acceptance Criteria
ExploratoryTesting
Automated UI Tests
TESTS
PERFORMENCE
Automated Unit Test
7Saturday 2 March 2013
Commercial Break!
8Saturday 2 March 2013
Copyright © 2013, AgileFAQs. All Rights Reserved.
9Saturday 2 March 2013
Mumbai10Saturday 2 March 2013
Tech Talks!
11Saturday 2 March 2013
12Saturday 2 March 2013
13Saturday 2 March 2013
13Saturday 2 March 2013
Copyright © 2013, AgileFAQs. All Rights Reserved.
Veterinarian Information System
14Saturday 2 March 2013
15Saturday 2 March 2013
Outside In: ATDDFitnesse Document:Assertions: 17 right, 0 wrong, 0 ignored, 0 exceptions
com.vis.billing.fixtures.PaidCashBill
account details
account number patient name owner name
1001 Fluffy Dave Atkins
procedure detailsname cost
Routine Office Visit 250
Rabies Vaccination 50
bill
account number? owner name? patient name? total? paid?
1001 Dave Atkins Fluffy 300 false
procedure details on the bill
name cost
Routine Office Visit 250
Rabies Vaccination 50
pay Cash
patient name? owner name? account number? bill no? payment method? amount paid?
Fluffy Dave Atkins 1001 1 Cash 300
check paid true
check total 0
16Saturday 2 March 2013
Outside In: Output
17Saturday 2 March 2013
ATDD: Another ExampleAcceptance test:class FluffyTest < Test::Unit::TestCase def test_examination_and_shots vet = Veterinarian.new clinic = Clinic.new "Main Line health" dave = Owner.new "Dave" fluffy = Patient.new "Fluffy" dave.has fluffy visit = clinic.visit(fluffy, vet) do |v| v.procedure "Rabies vaccination", 50 end invoice = visit.invoice assert_equal invoice.to_s, <<-INVOICE Routine visit: $200 Rabies vaccination: $50 Total: $250 INVOICE receipt = clinic.pay_for visit, 100 assert_equal receipt.to_s, <<-RECEIPT Paid $100 for Routine visit Paid $0 for Rabies vaccination Outstanding: $150 RECEIPT endend
18Saturday 2 March 2013
Outside In: Output
19Saturday 2 March 2013
Inside Out: Unit TDDpublic class ClinicTest { private Clinic clinic = new Clinic();
@Test public void amountOnTheReceiptShouldMatchBillableAmount() throws Exception { Billable billable = new Billable() { public int totalAmount() { return 0; } }; Account dave = new Account(101, "Dave");
Receipt rcpt = clinic.payCash(dave, billable); assertEquals("Amount on receipt does match procedure cost", billable.totalAmount(), rcpt.getAmount()); }
@Test public void customerPayesBillableAmountForCashTransaction() throws Exception { final int billableAmount = 56; class AmountCharged { int charged; }; final AmountCharged charged = new AmountCharged();
Billable billable = new Billable() { public int totalAmount() { return billableAmount; } };
Account dave = new Account(101, "Dave") { public void charge(int amount) { charged.charged = amount; } };
clinic.payCash(dave, billable); assertEquals("Account is not charged billable amount", billableAmount,charged.charged); }}
public class BillableTest {
private static final Account daveSAccount = new Account(101, "Dave"); private static final List<Service> services = new ArrayList<Service>();
@Test public void totalBillableAmountShouldBeZeroIfNoServicesAreProvided() { Billable bill = new Bill(daveSAccount, services); assertEquals("Total amount is not Zero", 0, bill.totalAmount()); }
@Test public void totalBillableAmountShouldBeTotalOfEachServiceProvided() { services.add(new Procedure("Rabies Vaccination", 250)); services.add(new Procedure("Regular office Visit", 50));
Billable bill = new Bill(daveSAccount, services);
assertEquals("Total Amount is not 300", 300, bill.totalAmount()); }
@After public void cleanUp() { services.clear(); }}
20Saturday 2 March 2013
Inside Out: Output
21Saturday 2 March 2013
Inside Out: Another Examplepublic class ChargeAccountForServices { private static final Billable bill = createMock(Billable.class); private static final Accountable account = createMock(Accountable.class); private static final Clinic clinic = new Clinic();
@Before public void setUp() { reset(account); reset(bill); }
@Test public void shouldMakePaymentsAgainstAnAccount() { account.paid(bill); replay(account); clinic.pay(300, bill, account); verify(account); }
@Test public void shouldHaveZeroAmountDueOnReceiptIfCompletePaymentIsMade() { expect(bill.amount()).andReturn(300); replay(bill); Receipt receipt = clinic.pay(300, bill, account); verify(bill); assertEquals(300, receipt.amount()); assertEquals(0, receipt.amountDue()); }
@Test public void shouldDisplayAmountDueOnTheReceiptIfIncompletePaymentIsMade() { expect(bill.amount()).andReturn(500); replay(bill); Receipt receipt = clinic.pay(300, bill, account); verify(bill); assertEquals(300, receipt.amount()); assertEquals(200, receipt.amountDue()); }}
22Saturday 2 March 2013
public class CreateBillForClientAccount { private static final List<Service> services = new ArrayList<Service>(); private static final Accountable account = createMock(Accountable.class); private Bill bill;
@Before public void setUp() { reset(account); }
@Test public void shouldThrowExceptionIfAccountIsNotDueForPayment() { expect(account.isPaymentDue()).andReturn(false); replay(account); try { new Bill(account, null); } catch (NoPaymentDueException e) { // expected } verify(account); }
@After public void cleanUp() { services.clear(); }
@Test public void shouldCreateABillWithTheTotalCostOfAllTheServices() { IMocksControl control = createControl(); Service rabiesVaccination = control.createMock(Service.class); Service routineVisit = control.createMock(Service.class); services.add(rabiesVaccination); services.add(routineVisit);
expect(account.isPaymentDue()).andReturn(true); expect(account.unpaidServices()).andReturn(services); bill();
expect(rabiesVaccination.cost()).andReturn(250); expect(routineVisit.cost()).andReturn(50);
control.replay();
assertEquals(300, bill.amount()); control.verify(); }
private void bill() throws NoPaymentDueException { replay(account); bill = new Bill(account, null); verify(account); }}
23Saturday 2 March 2013
Inside Out: Output
24Saturday 2 March 2013
Copyright © 2013, AgileFAQs. All Rights Reserved.
Where do you Stand?
Unit Test x Acceptance test
API x User Interface
State x Interaction
OO x Procedural
Easy x Core
Narrow x Broad
Drive Design x Validate Design
25Saturday 2 March 2013
Copyright © 2013, AgileFAQs. All Rights Reserved.
Bonus Calculator
Sales Quota Commission % Tax % Result1200 1100 10 10 91200 1500 10 10 01200 1200 10 10 0
26Saturday 2 March 2013
Copyright © 2013, AgileFAQs. All Rights Reserved.
Sales TaxBasic sales tax is applicable at a rate of 10% on all goods, except books, food, and medical products that are exempt. Import duty is an additional sales tax applicable on all imported goods at a rate of 5%, with no exemptions.
When I purchase items I receive a receipt which lists the name of all the items and their price (including tax), finishing with the total cost of the items, and the total amounts of sales taxes paid.
Write an application that prints out the receipt details for these shopping baskets...
Input 1:1 book at 12.491 music CD at 14.991 chocolate bar at 0.85
Output 1:1 book : 12.491 music CD: 16.491 chocolate bar: 0.85Sales Taxes: 1.50Total: 29.83
Input 2:1 imported box of chocolates at 10.001 imported bottle of perfume at 47.50
Output 2:1 imported box of chocolates: 10.501 imported bottle of perfume: 54.65Sales Taxes: 7.65Total: 65.15
Input 3:1 imported bottle of perfume at 27.991 bottle of perfume at 18.991 packet of headache pills at 9.751 box of imported chocolates at 11.25
Output 3:1 imported bottle of perfume: 32.191 bottle of perfume: 20.891 packet of headache pills: 9.751 imported box of chocolates: 11.85Sales Taxes: 6.70Total: 74.68
27Saturday 2 March 2013
Copyright © 2013, AgileFAQs. All Rights Reserved.
Medical System Age Calculating Program
28Saturday 2 March 2013
Copyright © 2013, AgileFAQs. All Rights Reserved.
Medical System Age Calculating ProgramAge Reported in
Greater than 1 Year <Patient Name> is # Years old
> 1 Month & < 1 Year <Patient Name> is # Months old
> 1 Day & < 1 Month <Patient Name> is # Days old
> 1 Hr & < 1 Day <Patient Name> is # Hours old
28Saturday 2 March 2013
Copyright © 2013, AgileFAQs. All Rights Reserved.
Medical System Age Calculating ProgramAge Reported in
Greater than 1 Year <Patient Name> is # Years old
> 1 Month & < 1 Year <Patient Name> is # Months old
> 1 Day & < 1 Month <Patient Name> is # Days old
> 1 Hr & < 1 Day <Patient Name> is # Hours old
Doctors and Nurses might like to add and remove new Durations.For Ex: If they add Decade, and Patient’s age is greater than 10 years, then age should be reported as <Patient Name> is # Decades old.
Similarly: If they add Week, and Patient’s age is greater than 7 Day, but less than a month, then age should be reported as <Patient Name> is # Weeks old.
28Saturday 2 March 2013
Copyright © 2013, AgileFAQs. All Rights Reserved.
Meeting Assistant
29Saturday 2 March 2013
Copyright © 2013, AgileFAQs. All Rights Reserved.
Coffee Vending MachineAgileWorks just contracted you to design and build a set of coffee machines for their work place. There are mechanical designers taking care of all the mechanical parts of the machines. You are responsible for the machine's controlling software.
AgileWorks’ requirements are very simple. They want to sell coffee, with or without cream powder and sugar, for $0.35. The front panel will have 4 buttons, for Black, Cream, Sugar and Cream&Sugar. There will also be a Coin Return button. The machine will take (American) coins only, and give change.
Any other displays are up to you to decide on and design. There will be dispensers that can dispense a fixed amount of: cup, hot water, coffee powder, cream powder, sugar.
The basic operations that your machine should be able to perform are• Accept money• Accept coffee selection• Provide coffee • Return change • Allow refill of dispensers • Handle boundary conditions such as insufficient money or material.
You may add any other aspects of your own.
30Saturday 2 March 2013
Copyright © 2013, AgileFAQs. All Rights Reserved.
Where do you Stand?
Unit Test x Acceptance test
API x User Interface
State x Interaction
OO x Procedural
Easy x Core
Narrow x Broad
Drive Design x Validate Design
31Saturday 2 March 2013
Copyright © 2013, AgileFAQs. All Rights Reserved.
Thank you
Naresh Jainnaresh@agilefaqs.com
32Saturday 2 March 2013
top related