μBERT: Mutation Testing using Pre-Trained Language Models

Renzo Degiovanni, Mike Papadakis
3/7/2022
cs.SE

Official code: rdegiovanni/mBERT (18 stars, Java, last commit 2025-08-20).

Abstract

We introduce $μ$BERT, a mutation testing tool that uses a pre-trained language model (CodeBERT) to generate mutants. This is done by masking a token from the expression given as input and using CodeBERT to predict it.

Show full abstract

Thus, the mutants are generated by replacing the masked tokens with the predicted ones. We evaluate $μ$BERT on 40 real faults from Defects4J and show that it can detect 27 out of the 40 faults, while the baseline (PiTest) detects 26 of them. We also show that $μ$BERT can be 2 times more cost-effective than PiTest, when the same number of mutants are analysed. Additionally, we evaluate the impact of $μ$BERT's mutants when used by program assertion inference techniques, and show that they can help in producing better specifications. Finally, we discuss about the quality and naturalness of some interesting mutants produced by $μ$BERT during our experimental evaluation.

View on arXivView PDF

Code Implementations(1)

rdegiovanni/mBERTOfficial100%

mBERT is a mutation testing tool that uses a pre-trained language model (CodeBERT) to generate mutants.

186Java, PythonMar 2, 20221 years ago

Similar Papers

Cite this paper

@article{degiovanni2022bert,
  title  = {μBERT: Mutation Testing using Pre-Trained Language Models},
  author = {Renzo Degiovanni and Mike Papadakis},
  year   = {2022},
  eprint = {2203.03289},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2203.03289}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2203.03289.svg)](https://codeofpaper.com/paper/2203.03289)

Discussion