Jorge Gonzalez Pliego

To Me My X-Tests! - Mutation testing Strategies

Our tests had 100% coverage, but a critical bug still slipped through. See how mutation testing found the flaw our 'perfect' test suite completely missed.

To Me My X-Tests! - Mutation testing Strategies
#1about 5 minutes

Understanding the illusion of 100% test coverage

High test coverage is a vanity metric because it only measures code execution, not the quality or value of the verification.

#2about 2 minutes

Stabilize your test suite before starting mutation testing

Before implementing mutation testing, ensure your existing unit and integration tests are stable and not flaky to get meaningful results.

#3about 1 minute

Exploring language-agnostic mutation testing tools

Mutation testing is a language-agnostic philosophy with various tools available like StrykerJS for TypeScript, Mutmut for Python, and others.

#4about 3 minutes

A live demo of the sample web store application

The demonstration walks through a simple e-commerce application built with TypeScript to showcase how mutation testing works in a real project.

#5about 3 minutes

Achieving 100% code coverage with weak assertions

Running the initial test suite shows 100% coverage, but a closer look reveals weak assertions that don't validate business logic correctly.

#6about 5 minutes

Installing and configuring the StrykerJS mutation tester

Follow the steps to install StrykerJS dependencies and create a configuration file to specify the package manager, reporters, and files to mutate.

#7about 4 minutes

Running StrykerJS and analyzing the initial mutation score

The first StrykerJS run reveals a low mutation score, indicating that many "mutants" survived because the existing tests were not strong enough to catch them.

#8about 3 minutes

Improving the mutation score by strengthening assertions

By replacing a weak `toBeDefined` check with a specific assertion that validates business logic, the test can now "kill" more mutants.

#9about 3 minutes

Verifying improvement by re-running the mutation tests

After strengthening the test assertion, re-running StrykerJS on the specific file shows a significant increase in the mutation score.

#10about 3 minutes

Integrating mutation testing into your CI/CD pipeline

Mutation testing reports can be integrated into CI/CD workflows like GitHub Actions to provide immediate feedback and block pull requests that don't meet a quality threshold.

#11about 1 minute

Final summary and key takeaways on mutation testing

The key takeaway is that test coverage is an illusion, and mutation testing helps ensure your tests provide real verification and value.

Related jobs
Jobs that call for the skills explored in this talk.

Featured Partners

Related Articles

View all articles

From learning to earning

Jobs that call for the skills explored in this talk.