chiefmyron / phpunit-test-workbench

An extension to integrate PHPUnit with the native Test Explorer functionality within VS Code. Zero configuration required for common environment setups.
https://marketplace.visualstudio.com/items?itemName=chiefmyron.phpunit-test-workbench
MIT License
5 stars 2 forks source link

code loading issues fail silently. #74

Closed FrankCoder closed 3 months ago

FrankCoder commented 11 months ago

I could not figure out why the tests would not run until I tried another phpunit test explorer, which output that php could not load the required file from the location specified. I moved a file and forgot to adjust the requirement.

To be quite honest, this is really frustrating. Your runner needs to forward any problem loading and running the code to the output like VSCode PHPUnit does.

If you write tests first, you really need to see any issue. If I had tried to run this in the web browser, I would have seen the error way sooner. Now I've lost a lot of time, looking in the wrong place, to figure out why it just looked like the test was not running.

testrunresult

Overall, I prefer this extension over vscode phpunit ... except for this stupid loss of time.

chiefmyron commented 11 months ago

Hi @FrankCoder, thanks for raising the issue. I'm travelling at the moment, but I'll look into it as soon as I can.

One thing I will say is that the output from the extension is almost directly piped from the phpunit binary - if it didn't find an issue with the file, then it's very unlikely that the extension would either. There are some basic checks that the extension performs to identify tests, but it doesn't go to the level of verifying the existence of included files - that's better suited to a language server.

That said, if you give me some more details about the before and after of the file in question, I will see if there are other checks I can add in.

FrankCoder commented 11 months ago

Hi @chiefmyron, thanks for the reply.

Yeah, sorry about the annoyed tone. I'm switching my whole project to use autoload, which will avoid this problem entirely.

Essentially the code file I was testing had a bad require statement, failing to load a dependency.

In phpunit-test-workbench I just get no test summary, whereas in vscode.phpunit I get a stack trace that shows the failing require statement.

At the very least, when no test summary info is available, maybe provide an indication that the code being tested may not be loading.

With best practices in place, this should never happen ... but then again, there is a lot of poorly structured projects out there as mine was ;-)

chiefmyron commented 10 months ago

Hi @FrankCoder - are you able to provide me with a before and after version of the file in question? Or a screenshot / sample test case that I can use to recreate the issue?

FrankCoder commented 10 months ago

Hi @chiefmyron,

Literally: require_once DIR."/../myfile.php"; // test ran with no summary // and no breakpoints hit because code file could not be found Changed to: require_once DIR."/../../myfile.php"; //Test ran correctly and breakpoints were hit.

Now I don't have a require_once anywhere but in my entry points to load autoload.php.

Hope this helps.

Now the require_once

chiefmyron commented 5 months ago

Hi @FrankCoder - recent versions of the extension have changed the way it reports errors and output from the PHPUnit binary. Are you still seeing this issue? If not, I will close down the issue.

FrankCoder commented 5 months ago

Hi @chiefmyron, Sorry for the late reply, I have not been working in PHP for the last few months, so I don't know if it's still an issue. If I get a chance, I will try and reproduce the problem sometime in June.

Right now, I am deeply concentrated on a new project.

Cheers!