Я использую PHP7.1 в последней версии Netbeans и пытаюсь запустить PHPUnit 6.5 вместе с ним.Когда я запускаю тесты в Netbeans, они не выполняются, и в окне вывода отображается следующая трассировка стека:
"C:\bin\phpunit.bat" "--colors" "--log-junit" "C:\Users\rwinkler\AppData\Local\Temp\nb-phpunit-log.xml" "C:\bin\phpunit.phar"
Fatal error: Uncaught PHPUnit\Runner\Exception: Class 'C:\bin\phpunit' could not be found in 'C:\bin\phpunit.phar'. in phar://C:/bin/phpunit.phar/phpunit/Runner/StandardTestSuiteLoader.php:102
Stack trace:
#0 phar://C:/bin/phpunit.phar/phpunit/Runner/BaseTestRunner.php(130): PHPUnit\Runner\StandardTestSuiteLoader->load('C:\\bin\\phpunit', 'C:\\bin\\phpunit....')
#1 phar://C:/bin/phpunit.phar/phpunit/Runner/BaseTestRunner.php(73): PHPUnit\Runner\BaseTestRunner->loadSuiteClass('C:\\bin\\phpunit', 'C:\\bin\\phpunit....')
#2 phar://C:/bin/phpunit.phar/phpunit/TextUI/Command.php(169): PHPUnit\Runner\BaseTestRunner->getTest('C:\\bin\\phpunit', 'C:\\bin\\phpunit....', Array)
#3 phar://C:/bin/phpunit.phar/phpunit/TextUI/Command.php(148): PHPUnit\TextUI\Command->run(Array, true)
#4 C:\bin\phpunit.phar(570): PHPUnit\TextUI\Command::main()
#5 {main}
thrown in phar://C:/bin/phpunit.phar/phpunit/Runner/StandardTestSuiteLoader.php on line 102
PHP Fatal error: Uncaught PHPUnit\Runner\Exception: Class 'C:\bin\phpunit' could not be found in 'C:\bin\phpunit.phar'. in phar://C:/bin/phpunit.phar/phpunit/Runner/StandardTestSuiteLoader.php:102
Stack trace:
#0 phar://C:/bin/phpunit.phar/phpunit/Runner/BaseTestRunner.php(130): PHPUnit\Runner\StandardTestSuiteLoader->load('C:\\bin\\phpunit', 'C:\\bin\\phpunit....')
#1 phar://C:/bin/phpunit.phar/phpunit/Runner/BaseTestRunner.php(73): PHPUnit\Runner\BaseTestRunner->loadSuiteClass('C:\\bin\\phpunit', 'C:\\bin\\phpunit....')
#2 phar://C:/bin/phpunit.phar/phpunit/TextUI/Command.php(169): PHPUnit\Runner\BaseTestRunner->getTest('C:\\bin\\phpunit', 'C:\\bin\\phpunit....', Array)
#3 phar://C:/bin/phpunit.phar/phpunit/TextUI/Command.php(148): PHPUnit\TextUI\Command->run(Array, true)
#4 C:\bin\phpunit.phar(570): PHPUnit\TextUI\Command::main()
#5 {main}
thrown in phar://C:/bin/phpunit.phar/phpunit/Runner/StandardTestSuiteLoader.php on line 102
Done.
Мой тест - это пример теста, который я извлек из учебника:
<?php
require_once 'PHPUnit/Autoload.php';
declare(strict_types=1);
use PHPUnit\Framework\TestCase;
final class EmailTest extends TestCase
{
public function testCanBeCreatedFromValidEmailAddress(): void
{
$this->assertInstanceOf(
Email::class,
Email::fromString('user@example.com')
);
}
public function testCannotBeCreatedFromInvalidEmailAddress(): void
{
$this->expectException(InvalidArgumentException::class);
Email::fromString('invalid');
}
public function testCanBeUsedAsString(): void
{
$this->assertEquals(
'user@example.com',
Email::fromString('user@example.com')
);
}
}