I spent whole day on this trying to make it work and since googling the problem does not yield many results, I'm assuming I'm doing something stupidly wrong and will appreciate if someone could point it out.
The title says it all — my tests are not discovered by VS Test Explorer, no matter what I try. I ended up recreating the most basic setup starting with PHP Web Project, adding phpunit.xml from template and adding BasidTest.php from template. I put all files in the root of the project, so there's no mistakes in directory path. My phpunit.xml looks like this:
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd"
backupGlobals = "false"
backupStaticAttributes = "false"
colors = "true"
convertErrorsToExceptions = "true"
convertNoticesToExceptions = "true"
convertWarningsToExceptions = "true">
<testsuites>
<testsuite name="Default Test Suite">
<directory>.</directory>
</testsuite>
</testsuites>
<php>
<env name="APP_ENV" value="testing"/>
</php>
</phpunit>
and my BasicTest.php is this:
<?php
use PHPUnit\Framework\TestCase;
final class BasicTest extends TestCase
{
public function testFunction() {
$this->assertEquals(2, 1 + 1);
}
}
I expected this to work with the built-in PHPUnit, but it does not. Adding phpunit/phpunit dependency as a composer package makes no difference. The output is always this:
========== Starting test discovery ==========
No test is available in C:\Users\ssshu\source\repos\PHPWebProject1\.vs\TestAdapter\PHPWebProject1.phpunit. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again.
========== Test discovery finished: 0 Tests found in 1.3 sec ==========
No tests found to run.
I tried building/rebuilding solution, closing and reopening Visual Studio, creating PHP Console project, changing processor architecture, rebooting, even uninstalling and reinstalling the extension, all to no avail. I'm updating the Visual Studio itself right at this moment, but it was fairly recent version (last updated 4 months ago), so I don't hold much hope.
Could anyone please help?