recca0120 / vscode-phpunit

The VS Code Test Explorer extension for PHPUnit
MIT License
129 stars 44 forks source link

No tests have been found in this workspace yet #205

Open ili101 opened 1 week ago

ili101 commented 1 week ago

Hi, updated from 3.2.2 to 3.4.2.

/srv/.vscode/settings.json

{
    "phpunit.phpunit": "/srv/api/bin/phpunit",
    "phpunit.args": [
        "--configuration /srv/api/phpunit.xml.dist"
    ],
}

/srv/api/phpunit.xml.dist

<?xml version="1.0" encoding="UTF-8"?>

<!-- https://phpunit.readthedocs.io/en/latest/configuration.html -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
         backupGlobals="false"
         colors="true"
         bootstrap="tests/bootstrap.php"
         convertDeprecationsToExceptions="false"
         displayDetailsOnTestsThatTriggerWarnings="true"
>
    <php>
        <ini name="display_errors" value="1" />
        <ini name="error_reporting" value="-1" />
        <server name="APP_ENV" value="test" force="true" />
        <server name="SHELL_VERBOSITY" value="-1" />
        <server name="SYMFONY_PHPUNIT_REMOVE" value="" />
        <server name="SYMFONY_PHPUNIT_VERSION" value="9.6" />
    </php>

    <testsuites>
        <testsuite name="Project Test Suite">
            <directory>tests</directory>
        </testsuite>
    </testsuites>

    <coverage processUncoveredFiles="true">
        <include>
            <directory suffix=".php">src</directory>
        </include>
    </coverage>

    <listeners>
        <listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener" />
    </listeners>

    <extensions>
    </extensions>
</phpunit>

Test file: /srv/api/tests/Api/FlowTest.php (also tried to copy to /srv/api/tests/FlowTest.php or set <directory> to /srv/api/tests/Api)

Testing from terminal:

root ➜ / $ /srv/api/bin/phpunit --configuration /srv/api/phpunit.xml.dist
PHPUnit 10.5.24 by Sebastian Bergmann and contributors.

Runtime:       PHP 8.3.13
Configuration: /srv/api/phpunit.xml.dist

SEEEE                                                               5 / 5 (100%)
...
recca0120 commented 1 week ago
{
    "phpunit.phpunit": "/srv/api/bin/phpunit",
    "phpunit.args": [
        "--configuration", "/srv/api/phpunit.xml.dist"
    ],
}
ili101 commented 1 week ago

Changed, still not detected.

ghnp5 commented 1 week ago

Same.

This is my config:

    "phpunit.command": "node ./phpunit-wrapper.mjs",
    "phpunit.php": "",
    "phpunit.phpunit": "",
ljubadr commented 1 week ago

Since I updated to version 3.4.2 extension is not finding tests. Latest version which works for me is 3.3.9

In my phpunit.xml I have

<testsuites>
    <testsuite name="Functional">
        <directory suffix="Test.php">packages/*/Tests</directory>
    </testsuite>
    ...
</testsuites>

If I replace * with specific folder

<directory suffix="Test.php">packages/Package1/Tests</directory>

then it returns tests in versions after 3.3.9

dp-anto commented 1 week ago

I have the same problem of this issue (which is the same as the one of 2 weeks ago)

recca0120 commented 1 week ago

Since I updated to version 3.4.2 extension is not finding tests. Latest version which works for me is 3.3.9

In my phpunit.xml I have

<testsuites>
    <testsuite name="Functional">
        <directory suffix="Test.php">packages/*/Tests</directory>
    </testsuite>
    ...
</testsuites>

If I replace * with specific folder

<directory suffix="Test.php">packages/Package1/Tests</directory>

then it returns tests in versions after 3.3.9 @ljubadr Allow packages/*/Tests starting from version 3.4.4."

recca0120 commented 1 week ago

The test files are not displayed; you can refer to #188 for more details.

ili101 commented 1 week ago

It looks like my problem is that absolute paths are not working. With my original config that worked before and works from terminal /srv/api/bin/phpunit --configuration /srv/api/phpunit.xml.dist the extension doesn't detect the XML:

    "phpunit.args": [
        "--configuration", "/srv/api/phpunit.xml.dist"
    ],

if I change it to:

    "phpunit.args": [
        "--configuration", "./api/phpunit.xml.dist"
    ],

Extention finds the XML (in /srv/api/phpunit.xml.dist) but PHPUnit looks for it in /srv/api/api/phpunit.xml.dist.

I think absolute paths need to be fixed so I can use my original config or something like what is suggested in the phpunit.args configuration example:

    "phpunit.args": [
        "--configuration", "${workspaceFolder}/api/phpunit.xml.dist"
    ],
ljubadr commented 1 week ago

@recca0120 I just tested 3.4.4 that you mentioned here and it finds tests with packages/*/Tests

One thing that I noticed is that in this vscode extension packages/*/Tests is case sensitive so it won't match packages/Package2/tests

Current phpunit.xml config

<directory suffix="Test.php">packages/*/Tests</directory>

will match both tests packages/.../Tests and packages/.../tests. I tested this by running

phpunit --list-tests

My phpunit/phpunit version is 9.6.10

ghnp5 commented 1 week ago

@recca0120 - thanks for your efforts!

But I just want to say that 3.4.7 is still broken for me 😊

3.3.9 was working well.

Thanks again.

recca0120 commented 2 days ago

@ghnp5 you can install version > 3.4.9, maybe fix your problem.

ghnp5 commented 2 days ago

Thanks. I tried 3.4.10, but it still doesn't find any tests. :(

What is the method the extension finds the Test php files? Is it in some config?

The reason I ask is because the settings I have are these:

"phpunit.command": "node ./phpunit-wrapper.mjs",
"phpunit.php": "",
"phpunit.phpunit": "",

Which means I'm not passing any path/wildcard to say where the tests are.

The tests are inside a folder called something/tests/, with a file called __phpunit.xml with the configs for the tests.

So, unless the extension does a full scan to the whole repository to find the tests, I'm not seeing what other way the extension would know where the tests are.

Thanks!

Etra-0 commented 1 day ago

I started experiencing this issue recently where the tests are not appearing in the testing section like they used to. I do remote development through SSH and docker/sail. Never had issues before, didn't change any config either. Version 3.4.10 btw.