1

When a test fails, I want to run a function (that searches for a certain string in a database and then greps for that string in a bunch of files) and output the results - is that possible?

For context, the test searches for two columns in a database. When it fails, I want to know if the string appears in one of the columns, and I also want to search a file for the string as well.

2 Answers 2

1

You can do that in an extension. The AfterTestFailureHook is what you're looking for.

1

You can overwrite PHPUnit\Framework\TestCase::onNotSuccessfulTest(Throwable $t). This method is called after a test has failed. Do not forget to call parent::onNotSuccessfulTest($t), though.

Not the answer you're looking for? Browse other questions tagged or ask your own question.