我正在尝试执行PHPUnit测试,但PHPUnit没有读取我文件中的任何测试:
hm@BP_PC3:/mnt/c/MAMP/htdocs$ phpunit
PHPUnit 6.0.10 by Sebastian Bergmann and contributors.
Time: 126 ms, Memory: 8.00MB
No tests executed!
但是当我运行./vendor/bin/phpunit时,我看到以下输出:
PHP Fatal error: Class 'PHPUnit_Framework_TestCase' not found in /mnt/c/MAMP/htdocs/test/unit/CalcTest.php on line 5
我已经像这样配置了我的文件:
<?xml version="1.0" encoding="UTF-8" ?>
<phpunit bootstrap="./vendor/autoload.php"
color="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
stopOnFailures="false"
syntaxCheck="false">
<testsuites>
<testsuite name="PHPUnit Tuts">
<directory>test</directory>
</testsuite>
</testsuites>
</phpunit>
那就是结构:
app - lib - calculator.php
|
test - unit - CalcTest.php
|
vendor - bin - (standard files)
|
composer.json
composer.lock
phpunit.xml
composer.json:
{
"autoload": {
"psr-4": {
"App\\": "app"
}
},
"autoload-dev": {
"files": ["test/unit/CalcTest.php"]
},
"require-dev" : {
"phpunit/phpunit": "^6.0"
}
}
这就是我的CalcTest.php的样子,实际上非常标准:
<?php
require_once 'PHPUnit/Autoload.php';
class CalcTest extends \PHPUnit_Framework_TestCase {
public function testAdd() {
$this->assertTrue(true);
}
}
?>
我试图删除composer.json中的“files”行,但它也没有用。