Coding Dojo:
Designing Test Cases for
the Gilded Rose Kata
June 2015
Peter Kofler, ‘Code Cop’
@codecopkofler
www.code-cop.org
Copyright Peter Kofler, licensed under CC-BY.
Peter Kofler
• Ph.D. (Appl. Math.)
• Professional Software
Developer for 15 years
• “fanatic about code quality”
• Freelance Code Mentor
PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY
Training
on the
Job?
PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY
Yes, some but...
●
only what is already there
●
Trial & Error not popular in production
●
no practice - only production
●
time pressure
I help development teams with
PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY
●
Professionalism
●
Quality and
Productivity
●
Continuous
Improvement
Mentoring
PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY
●
Pair Programming
●
Programming
Workshops
●
Deliberate
Practice, e.g.
Coding Dojos
Coding Dojo?
Expectations?
Coding Dojo Mindset
●
Safe place outside
work
●
We are here to learn
●
Need to slow down
●
Focus on doing it right
●
Collaborative Game
PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY
Dojo Structure
●
Introduction 15'
●
Coding 60'
●
Retrospective 15'
●
Break 15'
●
Coding 60'
●
Retrospective 15'
●
etc.
PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY
TDD Skills
●
Driving Development with Tests
●
Designing Test Cases 
●
Designing Clean Code
●
Refactoring Safely
PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY
Welcome to team Gilded Rose
PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY
The existing inventory system
●
We have items to sell. Items degrade in
quality the older they get.
●
All items have a SellIn value which
denotes the number of days we have to
sell the item.
●
All items have a Quality value which
denotes how valuable the item is.
PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY
Requirements
●
At the end of each day our system lowers
both values for every item.
●
Once the sell by date has passed, Quality
degrades twice as fast.
●
The Quality of an item is never negative.
●
The Quality is never more than 50.
PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY
Special Item: Brie
●
Aged Brie actually increases in Quality
the older it gets.
PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY
Backstage Passes
●
A backstage pass
increases in Quality
as it's SellIn value
approaches (by a
complex formula)
●
but Quality drops to
0 after the concert.
PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY
Special Item
●
Sulfuras, a legendary item, never has to
be sold or decreases in Quality.
PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY
Assignment
●
Get the code
●
Run tests, should see a failing test
●
Read GildedRoseRequirements.txt
●
Create “perfect” unit tests
●
derive test cases from requirements
●
cover all cases e.g. boundary conditions
●
readable, concise, free of duplication
PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY
Create a test suite
that is a readable
document at the
same time!
Don't Focus on
Getting it Done.
F0cus on Doing
It Perfectly.
→Practice
Closing Circle
●
What did you learn today?
●
What surprised you today?
●
What will you do
differently in the
future?
PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY
Peter Kofler
@codecopkofler
www.code-cop.org
Kata by
Emily Bache
@emilybache
http://coding-is-like-cooking.info/2013/03/writing-good-tests-for-the-gilded-rose-kata/
PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY
CC Images
●
Hamster http://www.flickr.com/photos/zebrapares/4529836138
●
Bruce http://www.flickr.com/photos/sherpas428/4350620602/
●
pairing http://www.flickr.com/photos/dav/94735395/
●
Dojo http://www.flickr.com/photos/49715404@N00/3267627038/
●
agenda http://www.flickr.com/photos/24293932@N00/2752221871/
●
inn http://www.flickr.com/photos/danielleblue/170496395/
●
Brie http://www.flickr.com/photos/chez_loulou/2767503201
●
Pass http://www.flickr.com/photos/frf_kmeron/5556518514
●
Sulfuras https://www.flickr.com/photos/sharelabs/11195626116
●
wants you http://www.flickr.com/photos/shutter/105497713/
PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY

Designing Test Cases for the Gilded Rose Kata v2 (2015)

  • 1.
    Coding Dojo: Designing TestCases for the Gilded Rose Kata June 2015 Peter Kofler, ‘Code Cop’ @codecopkofler www.code-cop.org Copyright Peter Kofler, licensed under CC-BY.
  • 2.
    Peter Kofler • Ph.D.(Appl. Math.) • Professional Software Developer for 15 years • “fanatic about code quality” • Freelance Code Mentor PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY
  • 3.
  • 4.
    PETER KOFLER, CODE-COP.ORGFANATIC ABOUT CODE QUALITY Yes, some but... ● only what is already there ● Trial & Error not popular in production ● no practice - only production ● time pressure
  • 5.
    I help developmentteams with PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY ● Professionalism ● Quality and Productivity ● Continuous Improvement
  • 6.
    Mentoring PETER KOFLER, CODE-COP.ORGFANATIC ABOUT CODE QUALITY ● Pair Programming ● Programming Workshops ● Deliberate Practice, e.g. Coding Dojos
  • 7.
  • 8.
    Coding Dojo Mindset ● Safeplace outside work ● We are here to learn ● Need to slow down ● Focus on doing it right ● Collaborative Game PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY
  • 9.
    Dojo Structure ● Introduction 15' ● Coding60' ● Retrospective 15' ● Break 15' ● Coding 60' ● Retrospective 15' ● etc. PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY
  • 10.
    TDD Skills ● Driving Developmentwith Tests ● Designing Test Cases  ● Designing Clean Code ● Refactoring Safely PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY
  • 11.
    Welcome to teamGilded Rose PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY
  • 12.
    The existing inventorysystem ● We have items to sell. Items degrade in quality the older they get. ● All items have a SellIn value which denotes the number of days we have to sell the item. ● All items have a Quality value which denotes how valuable the item is. PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY
  • 13.
    Requirements ● At the endof each day our system lowers both values for every item. ● Once the sell by date has passed, Quality degrades twice as fast. ● The Quality of an item is never negative. ● The Quality is never more than 50. PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY
  • 14.
    Special Item: Brie ● AgedBrie actually increases in Quality the older it gets. PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY
  • 15.
    Backstage Passes ● A backstagepass increases in Quality as it's SellIn value approaches (by a complex formula) ● but Quality drops to 0 after the concert. PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY
  • 16.
    Special Item ● Sulfuras, alegendary item, never has to be sold or decreases in Quality. PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY
  • 17.
    Assignment ● Get the code ● Runtests, should see a failing test ● Read GildedRoseRequirements.txt ● Create “perfect” unit tests ● derive test cases from requirements ● cover all cases e.g. boundary conditions ● readable, concise, free of duplication PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY
  • 18.
    Create a testsuite that is a readable document at the same time!
  • 19.
    Don't Focus on Gettingit Done. F0cus on Doing It Perfectly.
  • 20.
  • 21.
    Closing Circle ● What didyou learn today? ● What surprised you today? ● What will you do differently in the future? PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY
  • 22.
    Peter Kofler @codecopkofler www.code-cop.org Kata by EmilyBache @emilybache http://coding-is-like-cooking.info/2013/03/writing-good-tests-for-the-gilded-rose-kata/ PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY
  • 23.
    CC Images ● Hamster http://www.flickr.com/photos/zebrapares/4529836138 ● Brucehttp://www.flickr.com/photos/sherpas428/4350620602/ ● pairing http://www.flickr.com/photos/dav/94735395/ ● Dojo http://www.flickr.com/photos/49715404@N00/3267627038/ ● agenda http://www.flickr.com/photos/24293932@N00/2752221871/ ● inn http://www.flickr.com/photos/danielleblue/170496395/ ● Brie http://www.flickr.com/photos/chez_loulou/2767503201 ● Pass http://www.flickr.com/photos/frf_kmeron/5556518514 ● Sulfuras https://www.flickr.com/photos/sharelabs/11195626116 ● wants you http://www.flickr.com/photos/shutter/105497713/ PETER KOFLER, CODE-COP.ORG FANATIC ABOUT CODE QUALITY