recca0120 / vscode-phpunit

The VS Code Test Explorer extension for PHPUnit
MIT License
130 stars 45 forks source link

Tests No Longer Detected #188

Closed baschnipke closed 2 weeks ago

baschnipke commented 3 weeks ago

I'm not sure what info to provide. I was using the extension to test, then it stopped running tests for some reason so I restarted vscode, let vscode update, and now it just says no tests have been found in this workspace yet. It was working fine before. I'm using WSL2, Docker, and Sail. I've made no changes.

Are others having this issue?

baschnipke commented 3 weeks ago

Reverted to v3.2.2 and it works fine.

recca0120 commented 3 weeks ago

Did this happen in version 3.3.4?

ettdro commented 3 weeks ago

I'm also having this issue, yesterday I updated this extension to 3.3.3. Refreshing the tests was causing an error because it was looking in the wrong subdirectory, so I used v3.2.2 instead and it was ok. Now with 3.3.5, the error is gone, but when I refresh tests, the tests don't seem to be detectable.

recca0120 commented 3 weeks ago

you can try 3.3.5

ettdro commented 3 weeks ago

Tests are not detectable in 3.3.5 :(

ultimike commented 3 weeks ago

I am also using 3.3.5 and tests are not being detected for me either (MacOS, VSCode 1.95.1)

-mike

recca0120 commented 3 weeks ago

https://github.com/user-attachments/assets/96e24eb2-9aed-41b4-bbc9-f6fd88cbf5df

open phpunit.xml and check your tests folder is in testsuite directory

if your phpunit.xml is not in root directory, set configuration phpunit.args = ['-c', 'folder/phpunit.xml']

ultimike commented 3 weeks ago

My phpunit.xml is in my project directory.

Similar to @baschnipke and @ettdro - everything was working fine with the same project, same phpunit.xml, and same configuration prior to the extension's update.

Does this new version have a requirement that all test directories must be listed in <testsuites>? When I add that to my phpunit.xml things start working again...

-mike

madebycaliper commented 3 weeks ago

I just updated to v3.3.5 and already had a phpunit.xml file in my root. When I rename or delete that file to something else, the tests show up again. Curious if @ultimike is onto something 🤔

Edit: I just removed the ./ in front of my <testsuites> definition and that got it working

    <testsuites>
        <testsuite name="Unit">
-            <directory suffix="Test.php">./tests/Unit</directory>
+            <directory suffix="Test.php">tests/Unit</directory>
        </testsuite>
        <testsuite name="Feature">
-            <directory suffix="Test.php">./tests/Feature</directory>
+            <directory suffix="Test.php">tests/Feature</directory>            
        </testsuite>
    </testsuites>
ultimike commented 3 weeks ago

I always have (and need) a phpunit.xml file in my project root. It normally has other <testsuite> entries.

-mike

recca0120 commented 3 weeks ago

https://github.com/user-attachments/assets/a0c997b0-ae1e-4c47-8372-433315f3910d

here is my test

  1. testsuite
  2. sub folder
  3. no phpunit.xml, no tetsuite tag
madebycaliper commented 3 weeks ago

@recca0120 can you share the entire contents of your phpunit.xml file? I don't have the <source> tag like yours and curious to see if there are more details I'm missing that could be causing a problem

recca0120 commented 3 weeks ago

@madebycaliper here is my phpunit.xml for test and this is phpunit.xml for phpunit 11.5

ultimike commented 3 weeks ago

@recca0120 Was there a change in 3.3.5 that changed the way that the extension searches for test classes?

-mike

recca0120 commented 3 weeks ago

@ultimike yes, before 3.3.5 I made a mistake

https://github.com/recca0120/vscode-phpunit/commit/ac125c181b0c28bf85b08ab606e4536d5cc5351f#diff-04bba6a35cad1c794cbbe677678a51de13441b7a6ee8592b7b50be1f05c6f626L181

I can't find this error because my test files path is tests lol

ultimike commented 3 weeks ago

Testing this new update out a bit more...

In my phpunit.xml file, I have included the following:

    <testsuite name="default">
      <directory>modules</directory>
    </testsuite>

In my modules directory, there are 5 test classes, with a total of 13 test methods.

In the entire project, including directories outside of modules, there are literally thousands of tests (Drupal core 10.3.6 plus several contrib modules).

With the above configuration of my phpunit.xml file, the extension correctly shows only the tests in my modules directory.

But, when I click the "Run tests" button, ALL tests are run (yes, thousands of them). Obviously, this is not what I was hoping for.

Screenshot 2024-11-07 at 12 40 46 PM

-mike

recca0120 commented 3 weeks ago

https://github.com/user-attachments/assets/7f96896a-54d8-40a2-ace4-b1048d91cd5b

I click run all, it only run tests in the testsuite directory

when click run all, the command is vendor/bin/phpunit -c phpunit.xml, phpunit will scan tests by phpunit. not this extension.