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.

Sign up to request clarification or add additional context in comments.

Comments

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.