Netbeans没有运行PHPUnit测试

时间:2018-09-15 16:28:17

标签: netbeans phpunit php-7

我正在以最新的Netbeans版本运行PHP7.1,并试图与其一起运行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')
        );
    }
}

1 个答案:

答案 0 :(得分:0)

在评论中每个xmike:

“”我想您配置了错误的项目属性->测试-> PHPUnit->使用自定义测试套件(将其留空)“