Published Sep 5, 2024

SE Radio 632: Goran Petrovic on Mutation Testing at Google

Delve into Google's innovative use of mutation testing with Goran Petrovic, as he uncovers how this technique uncovers actual bugs, shapes developer practices, and overcomes initial challenges, ultimately enhancing test quality and software reliability.
Episode Highlights
Software Engineering Radio - the podcast for professional software developers logo

Popular Clips

Questions from this episode

Episode Highlights

  • Mutation Testing

    Mutation testing is a sophisticated method for assessing test suite effectiveness by introducing small faults, or "mutants," into software code. explains that unlike traditional test adequacy criteria such as code coverage, mutation testing evaluates whether tests can detect these intentional faults, providing a more robust measure of test quality 1. He notes that mutation testing involves creating multiple versions of code with slight changes, like altering arithmetic operations or deleting code blocks, and then running tests to see if they can identify these changes 2. This approach helps ensure that tests do more than just cover code; they validate its correctness 3.

    Programming is an art of adding bugs to your code and then removing them. Probably you never remove all of them.

    ---

    This method is particularly valuable in large-scale software development, where code longevity and frequent modifications increase the risk of undetected bugs.

       

    Benefits & Challenges

    Mutation testing significantly enhances test quality and software reliability by encouraging developers to write more effective test cases. highlights that this method not only increases the number of tests but also improves their ability to detect defects, as evidenced by a reduction in live mutants in code submissions at Google 4. He also discusses the coupling effect, where mutants resemble real bugs, thus tests that catch mutants are likely to catch actual bugs as well 5. However, implementing mutation testing is resource-intensive, requiring careful selection of mutants to ensure feasibility and effectiveness 6.

    If these tests had been written, had mutation testing been enabled, these bugs would have been prevented.

    ---

    Despite its challenges, mutation testing offers a compelling case for improving software quality by preemptively identifying potential defects.

       

    Tools & Automation

    Integrating mutation testing into existing workflows requires sophisticated tools and automation. At Google, the mutagenesis tool automates the mutation testing process by generating mutants and running tests against them, all integrated into the code review process 7. explains that this system minimizes developer disruption by focusing on code changes relevant to the current commit, thus optimizing resource use and developer attention 8. The tool supports multiple programming languages, including C, Python, Java, and Rust, making it versatile for various development environments 7.

    The best way to get developers to do something and to act on some results is to introduce the least amount of friction in their workflow.

    ---

    By seamlessly integrating into the development process, mutation testing tools like mutagenesis enhance software quality without overwhelming developers.

Related Episodes