Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Using code coverage and mutation testing to add...

Using code coverage and mutation testing to add tests to legacy code

Refactoring is a key skill needed when working with legacy code bases, and the easiest / safest way to do it is with good test coverage. But what if your legacy code base has no tests? This talk shows, with examples, how to use code coverage and mutation testing to add tests to your legacy code base.

This talk was delivered at MenderCon online on Thurs 16th May 2024: https://mendercon.com/schedule/#session-9

Clare Sudbery

May 16, 2024
Tweet

More Decks by Clare Sudbery

Other Decks in Programming

Transcript

  1. Demo: Using code coverage to add tests to existing code

    @ClareSudbery Using coverage to add tests
  2. @ClareSudbery Use coverage to find missing test data Doing the

    exercise yourself • Original code is here: https://github.com/emilybache/GildedRose-Refactoring-Kata • Requirements are in the readme • Run this command to clone the code: • git clone https://github.com/emilybache/GildedRose-Refactoring-Kata.git • Choose your language • My demo code is here: https://github.com/claresudbery/GildedRose-Refactoring- Kata/blob/coverage-demo-complete/csharpcore/GildedRoseTests/GildedRoseTest.cs
  3. @ClareSudbery • Original code is here: https://github.com/emilybache/GildedRose-Refactoring-Kata • Requirements are

    in the readme • Run this command to clone the code: • git clone https://github.com/emilybache/GildedRose-Refactoring-Kata.git • Choose your language • My demo code is here: https://github.com/claresudbery/GildedRose-Refactoring- Kata/blob/csharp-mutation-complete/csharpcore/GildedRoseTests/GildedRoseTest.cs Use mutation testing to find missing untested edge cases Doing the exercise yourself
  4. Relevant podcast episodes… @ClareSudbery Test Driven Development: tinyurl.com/mtb-geepaw-hill Refactoring: tinyurl.com/mtb-emily-bache

    Balancing Change: tinyurl.com/kevlin-henney-twitter Changing legacy systems: tinyurl.com/meri-williams- twitter
  5. Sudbery Software Engineering Ltd Does your team want help to

    improve their software delivery? Coaching, keynotes & workshops Events and info: tinyurl.com/csudbery Mastodon: mastodon.social/@ClareSudbery LinkedIn: tinyurl.com/lin-csudbery Podcast: tinyurl.com/tech-better-pod