# Learning How to Mutate Source Code from Bug-Fixes

**Authors:** Michele Tufano, Cody Watson, Gabriele Bavota, Massimiliano Di Penta,, Martin White, Denys Poshyvanyk

arXiv: 1812.10772 · 2019-07-31

## TL;DR

This paper introduces a deep learning-based method to automatically generate source code mutants from real bug fixes, improving mutation testing by creating more realistic and relevant mutants.

## Contribution

It presents a novel approach that learns mutation models from real bug fixes using deep learning, enabling automatic and effective mutant generation.

## Key findings

- Models predict mutants resembling real bugs in 9-45% of cases.
- Over 98% of generated mutants are syntactically and lexically correct.
- The approach was trained on ~787k bug fixes from GitHub.

## Abstract

Mutation testing has been widely accepted as an approach to guide test case generation or to assess the effectiveness of test suites. Empirical studies have shown that mutants are representative of real faults; yet they also indicated a clear need for better, possibly customized, mutation operators and strategies. While methods to devise domain-specific or general-purpose mutation operators from real faults exist, they are effort- and error-prone, and do not help the tester to decide whether and how to mutate a given source code element. We propose a novel approach to automatically learn mutants from faults in real programs. First, our approach processes bug fixing changes using fine-grained differencing, code abstraction, and change clustering. Then, it learns mutation models using a deep learning strategy. We have trained and evaluated our technique on a set of ~787k bug fixes mined from GitHub. Our empirical evaluation showed that our models are able to predict mutants that resemble the actual fixed bugs in between 9% and 45% of the cases, and over 98% of the automatically generated mutants are lexically and syntactically correct.

## Full text

_Full body text omitted from this summary view._ Fetch the complete paper as Markdown: https://tomesphere.com/paper/1812.10772/full.md

## Figures

3 figures with captions in the complete paper: https://tomesphere.com/paper/1812.10772/full.md

## References

64 references — full list in the complete paper: https://tomesphere.com/paper/1812.10772/full.md

---
Source: https://tomesphere.com/paper/1812.10772