

What I’ve learned by doing the Gilded Rose Kata (4 refactoring tips) - ArturT
http://blog.lunarlogic.io/2015/what-ive-learned-by-doing-the-gilded-rose-kata-4-refactoring-tips/

======
dalke
We did the Gilded Rose kata at one of our local Python user group meetings.

What I remember most about it, other than the complicated logic, was using
'coverage' in branch mode to find two places where the manually developed and
pretty comprehensive unit test suite was incomplete.

~~~
ArturT
In my repository [https://github.com/ArturT/GildedRose-Refactoring-
Kata/tree/s...](https://github.com/ArturT/GildedRose-Refactoring-
Kata/tree/solutions/ruby) you will find completed test suite also with golded
master tests. There are tests for additional item "Conjured Mana Cake" as
well.

~~~
dalke
I don't think I was clear so I will try again.

How does one pick the test cases for something like the GildedRose? Emily
Bache, who provided the test cases for this essay and who ran the Python user
group kata that I participated in, developed the test cases manually.

Are those provide test cases sufficient? As this essay shows, they are not.

The solution shown here "recorded bunch of input examples and output results
from the program we wanted to refactor." However, are those seeded versions
themselves sufficient?

Another solution is to use branch coverage testing to identify untested paths,
and write unit tests which specifically target those paths. When I did this
using Bache's unit test suite, I found that two branches were not exercised.

Even coverage analysis may not be sufficient. I mention it to suggest an
alternate technique that I found useful in working with this kata.

Coverage assisted test development is, in my opinion, an underused technique.

~~~
ArturT
"How does one pick the test cases for something like the GildedRose? Emily
Bache, who provided the test cases for this essay and who ran the Python user
group kata that I participated in, developed the test cases manually." I
created my tests based on empty example from Emily
[https://github.com/emilybache/GildedRose-Refactoring-
Kata/bl...](https://github.com/emilybache/GildedRose-Refactoring-
Kata/blob/master/ruby/gilded_rose_spec.rb) and right now I assume I have my
own tests covering all edge cases because I discovered edge cases with golden
master technique and I added missing tests to gilded_rose_spec.rb file.

"The solution shown here "recorded bunch of input examples and output results
from the program we wanted to refactor." However, are those seeded versions
themselves sufficient?" Golded Master tests are sufficient because I recorded
all possible cases of inputs/outputs for reasonable amount of sell in days.
See [https://github.com/ArturT/GildedRose-Refactoring-
Kata/blob/s...](https://github.com/ArturT/GildedRose-Refactoring-
Kata/blob/solutions/ruby/spec/golden_master_spec.rb)
[https://github.com/ArturT/GildedRose-Refactoring-
Kata/blob/s...](https://github.com/ArturT/GildedRose-Refactoring-
Kata/blob/solutions/ruby/texttest_fixture.rb)

"Even coverage analysis may not be sufficient." Agree.

"Coverage assisted test development is, in my opinion, an underused
technique." I guess you're right. I wouldn't relay only on test coverage.

