Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Alejandro Celaya:
Mutation testing with infection in big PHP projects
Feb 19, 2018 @ 15:39:58

Alejandro Celaya has a post on his site that shows how to use a less well-known testing tool - mutation testing - to test for variations on the "good" and "bad" data paths. In this article he makes use of the infection library that replaced the previously active Humbug library.

There's no doubt that having tests in a project allows you to find potential bugs earlier and more easily.

Lots of OSS projects require a minimum code coverage in order to accept new pull requests from contributors, and proprietary projects also tend to have some sort of continuous integration workflow which requires certain metrics to be fulfilled in order to get builds passing. However, the code coverage can lead to a false sense of security, which makes you think that if a certain class has a 100% code coverage, it is also 100% bug-free.

This is not always true since you could be calling a method and yet not being properly testing its output or its real behavior. The code coverage will mark it as covered, but you might introduce a bug and still have a green test. This is where mutation testing comes in.

He starts by briefly introducing the concepts of mutation testing and showing how to get the infection library installed and configured. He then gives a guide on running the tool and some of the command line options that can be used to configure threading, having it only run on covered code and setting the log verbosity. He then offers some advice on troubleshooting the use of the tool and how phpdbg is used to generate reports.

tagged: unittest mutation testing infection tutorial project

Link: https://blog.alejandrocelaya.com/2018/02/17/mutation-testing-with-infection-in-big-php-projects/


Trending Topics: