Skip to content

luontola/tdd-mooc-legacy-code

Repository files navigation

TDD MOOC: Legacy code

This is an exercise to practice dealing with legacy code. There are three things you need to do:

  1. Write test for the code src/gilded_rose.mjs, until it has 100% mutation test coverage.
  2. Refactor the code to make it understandable.
  3. Add the "conjured items" feature described in Gilded Rose requirements.

When writing the tests, at first use just line coverage (npm run coverage) to find non-tested lines. After all lines are tested, switch to using mutation coverage (npm run mutation) and improve your tests. Both commands write their reports in html format under the coverage directory.

(In real projects, mutation coverage typically takes many minutes to run, so for faster feedback it can be practical to first focus on just the line coverage.)

When refactoring, first try to see how far you can get without understanding the problem domain (i.e. use mechanical, provably correct refactorings). Then read the Gilded Rose requirements document to understand the problem domain and get a new perspective for improving the design.


This exercise is part of the TDD MOOC at the University of Helsinki, brought to you by Esko Luontola and Nitor. This exercise is based on the Gilded Rose Refactoring Kata by Emily Bache and Terry Hughes.

Prerequisites

You'll need a recent Node.js version. Then download this project's dependencies with:

npm install

Developing

Run tests once

npm run test

Run tests continuously

npm run autotest

Calculate line coverage, writes results to coverage/lcov-report/index.html

npm run coverage

Calculate mutation coverage, writes results to coverage/mutation-report/index.html

npm run mutation

Code reformat

npm run format