The Pitfalls of Test Coverage: Introducing Mutation Testing with Stryker and Cosmic Ray
Overview Goal: Overcome the limitations of Code Coverage metrics and introduce 'Mutation Testing' to verify if test codes actually catch errors in business logic. Scope: Core modules of the enterpr...
Source: dev.to
Overview Goal: Overcome the limitations of Code Coverage metrics and introduce 'Mutation Testing' to verify if test codes actually catch errors in business logic. Scope: Core modules of the enterprise orchestrator project (Ochestrator) in both Frontend (TypeScript) and Backend (Python). Expected Results: Improve code stability and test reliability by securing a 'Mutation Score' beyond simple line coverage. We often believe that high test coverage means safe code. However, it's difficult to answer the question: "Who tests the tests?" Tests that simply execute code without proper assertions still contribute to coverage metrics. To solve this 'coverage trap', we introduced mutation testing. Implementation 1. TypeScript Environment: Introducing Stryker Mutator For the TypeScript environment, including frontend and common utilities, we chose Stryker. It integrates well with Vitest and is easy to configure. Tech Stack: TypeScript, Vitest, Stryker Mutator Key Configuration (stryker.config.jso