Gitpod, Java Approvals, and the Gilded Rose Kata

The Gilded Rose is a really interesting one for exploring techniques to work with legacy code. It’s simple enough to make progress in an hour, but complex enough to be tricky.

GitPod is a cloud based development environment. It uses VSCode as the editor, either in the browser or through an extension in your desktop VSCode. It is really nice for ensemble programming on kata’s because it seems to work reasonably well with multiple people in the same workspace while providing some level of editor and refactoring support.

Unfortunately the VSCode Coverage story is still under development, so some compromises have to be made: it’s not possible to use the VSCode Java test runner and also get coverage.

Fortunately, we can run gradle in continuous mode to rerun tests and generate coverage every time we make a change, and we can use the Coverage Gutters extension to view that coverage in the editor.

My fork of the GildedRose-Refactoring-Kata already has fixes for generating coverage with JaCoCo, running juint tests within VSCode (even though coverage doesn’t work with it), a gradle upgrade necessary for VSCode, and VSCode specific configuration for making the coverage more visible. If you don’t need those things, you should use the original: Emily Bache’s GildedRose-Refactoring-Kata.

  1. Create a new gitpod workspace
  2. Narrow the scope of the editor by opening the folder (C-k C-o) for the Java-Approvals. This makes it easier to focus in on just the Java-Approvals variant of the kata, and prevents VSCode from suggesting extensions and trying to start language servers for all the other variations.
  3. Look for the recommendation to install the “Extension Pack for Java” extension in the lower right and click install.
  4. Wait for the extension to install. Open the Extension panel, clear the search box. Click “Reload Required” if it appears on any of the extensions.
  5. Look for “Build tool conflicts” in the lower right. Click “Use Gradle”.
  6. Look for the “A git repository…” box and click “Yes”
  7. Install the “Coverage Gutters” extension by ryanluker.
  8. In the Terminal, do cd Java-Approvals and ./gradlew test. The tests should fail.
  9. Find the *.received.txt files in test/java/com/gildedrose and rename them to .approved.txt. Commit them.
  10. Run ./gradlew test again and the tests should pass.
  11. Open GildedRose.java.
  12. Run the command “Coverage Gutters: Watch”
  13. In the Terminal, run ./gradlew --continuous test
  14. Do the Kata! For example, using the lift up conditional method, see Llewellyn Falco: From 0% to Cleanly Refactored 100% tested code - Craft Conference 2019 and Part 2/3 - Refactoring item logic using ‘lift up conditional’, Emily Bache for demonstrations.

If you don’t care about coverage, you can also run the tests using the VSCode Test Runner. One way to do this is to open GildedRoseApprovalTest.java, and find the little green play buttons in the left gutter. Click one of them and the Testing panel should open with the test results.