0
votes

Good day,

I'm trying to run my laravel 5.4.12 tests using phpunit 5.7.13. When I intentionally make a syntax error, phpunit will not continue as expected. However, once the syntax error is corrected, phpunit will execute, and just say "it works" on the command line. When I add an intentionally failing test, it will not show that error.

On my composer.json, I put the required-dev of phpunit to 5.7.

I am running php 5.6.15 on a windows machine.

Are there any incompatibilities between the phpunit and laravel? I tried running phpunit on a project with an older version of laravel and it managed to run all tests.

1
did it really runs the tests? I mean do you have output like this ".E..E"? it's possible that phpunit cannot find your tests - arku
That's what I'm thinking too. I'm just confused as to why it can see syntax errors in the test files, but not run the test files when I fix the syntax errors. - Jon Abaca
any output? try to die('asd'); in test file :) - arku
Okay, I think I found the problem. - Jon Abaca
so share it to help the next one who stepped in it :) - arku

1 Answers

0
votes

Laravel 5.2.41 phpunit.xml (the old project where phpunit is okay)

<testsuites>
    <testsuite name="Application Test Suite">
        <directory suffix="Test.php">./tests</directory>
    </testsuite>
</testsuites>

This makes phpunit enter the subdirectories and run every single test.

Laravel 5.4.12 phpunit.xml (the new project where phpunit does not run tests)

    <testsuites>
        <testsuite name="Feature Tests">
            <directory suffix="Test.php">./tests/Feature</directory>
        </testsuite>

Phpunit will not enter the subdirectories of ./tests/Feature. I needed to add "/*" to make it do so.

Why it just enters the subdirectories in the previous version of laravel, I'm still figuring that out.