Testing Tour #3: Exploring API testing with Maaret Pyhäjärvi

I had a 60 min session with Maaret where we initially discussed my goal for this session - which was 
to explore any open source API and write unit tests. Given Maaret comes with extensive experience, 
she suggested to start simple using the Gilded Rose Kata for our session. 

She already had the project setup on her laptop, so when we paired via zoom, we were able to 
switch control to write tests on her IDE. The first 20-25 mins, we spent trying to understand the 
requirements outlined here

Introduction: Gilded Rose is an inn in a prominent city where they buy and sell goods. 
Our task is to test this system based on the rules laid out.These were the basic ground rules:
  • All items have a SellIn value which denotes the number of days we have to sell the item
  • All items have a Quality value denoting how valuable it is
  • At the end of each day, our system lowers both values for each item
There were more rules concerning each type of item - which is where it gets interesting. Let's 
take the first rule and try to come up with test cases:
Once the sell by date has passed, quality degrades twice as fast
Based on the test fixture, we know that these elements were added to the system:
new Item("+5 Dexterity Vest", 10, 20), //
new Item("Aged Brie", 2, 0), //
new Item("Elixir of the Mongoose", 5, 7), 
new Item("Sulfuras, Hand of Ragnaros", 0, 80), 
new Item("Sulfuras, Hand of Ragnaros", -1, 80),
new Item("Backstage passes to a TAFKAL80ETC concert", 15, 20),
new Item("Backstage passes to a TAFKAL80ETC concert", 10, 49),
new Item("Backstage passes to a TAFKAL80ETC concert", 5, 49),
// this conjured item does not work properly yet
new Item("Conjured Mana Cake", 3, 6) };

Consider the example of Elixir of the Mongoose - the sellIn date is 5 days and the quality value 
is 7.  When I try to call updateQuality(“Elixir of the Mongoose”) - the quality will decrease by 1 
each time. So if I had a for loop with the limit as 8 days, then my test should assert that the 
sellIn value would be -2 and the quality value would become 0. 

I played around by writing similar tests asserting the values accordingly and updating tests.
Maaret also had a code coverage tool plugged into her framework which made it easy for us 
to figure out our current coverage status. 

You can find some more tests that I added to my git repo here.
Maaret was patient and helpful to let me explore the API and come up with test cases during 
our session. 


Popular posts from this blog

Book Review: Leading Quality + Meeting notes by Tristan Lombard

Devops Book Review: Team Topologies

Testing Tour #4: Writing a book with Lisa Crispin