1

I have PHPUnit tests that use data providers as inputs, and by default these are outputted in a diff-like format (when running with php artisan test):

1) Tests\Feature\MyTest::test_feature with data set "12345678" ('12345678', '9999')
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-'9999'
+'0000'

...

2) Tests\Feature\MyTest::test_feature with data set "ABCDEFG" ('ABCDEFG', 'DEADBEEF')
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-'DEADBEEF'
+'00000000'

I have thousands of these tests and they can result in a lot of failing values, and I often need to extract these values to compare them and analyse them elsewhere.

Does PHPUnit and/or Laravel Artisan provide any way to output only the expected and actual values?

1
  • 1
    I imagine you'd have to register listeners for PHPUnit's events and handle the failures to your liking, probably similar to what the artisan test command is doing (that command and its output are part of the nunomaduro/collision package, FYI) Commented Oct 24 at 17:26

0

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.