0

I've just managed to get mutation testing working for the first time. My usual testing framework is Codeception but as of writing, it is not compatible with mutation testing (although I believe work is being done on it and it's not far off). I'm using PHPUnit and Infection, neither of which seem easy to work out how to use.

My test suite generated ten mutants. Nine were killed and one escaped. However, I don't know what part of the code or the tests needs to be improved to kill the final mutant.

How do you get information about what code allowed the mutant to escape?

CJ Dennis
  • 4,226
  • 2
  • 40
  • 69

1 Answers1

0

I found in this blog what I couldn't find in Infection's documentation: the results are saved in infection.log.

The log file looks like this:

Escaped mutants:
================


1) <full-path-to-source-file>.php:7    [M] ProtectedVisibility

--- Original
+++ New
@@ @@
 use stdClass;
 trait HiddenValue
 {
-    protected function hidden_value($name = null, $value = null)
+    private function hidden_value($name = null, $value = null)
     {
         static $data = [];
         $keys = array_map(function ($item) {

Timed Out mutants:
==================

Not Covered mutants:
====================

It says that the mutation changed the protected visibility to private and that no tests failed as a result. If this is important, I can now either change the code or write another test to cover this case.

Now that I've found this, I've searched on the Infection website for infection.log and found --show-mutations or -s which will output escaped mutants to the console while running.

CJ Dennis
  • 4,226
  • 2
  • 40
  • 69