首先,有些奇怪的是Netbeans中的某些测试正在运行,但只有一些在“更深层次”的测试不起作用。
结构:
Test
---Folder1
---Folder2
---Folder3
---Folder4
---Folder5
---Folder6
---testsThatWorkTest.php
---Folder6-2
---Folder7
---testThatDontWorkTest.php
---Folder7-2
---testInHereWorkTest.php
---bootstrap.php
---phpunit.xml
消息我在输出窗口中进入Netbeans:
PHPUnit 4.7.7 by Sebastian Bergmann and contributors.
Warning: No whitelist configured for code coverage
Time: 562 ms, Memory: 12.00Mb
No tests executed!
Generating code coverage report in PHP format ... done
消息我进入cmd:
PHPUnit 4.7.7 by Sebastian Bergmann and contributors.
Warning: No whitelist configured for code coverage
Time: 5.39 seconds, Memory: 20.75Mb
OK (1 test, 1 assertion)
Generating code coverage report in PHP format ... done
由于工作测试,我将假设所有设置在netbeans(tools-> options-> php-> phpunit以及“右键单击”属性 - >测试)中都是正确的。
phpunit.xml:
<phpunit colors="true"
bootstrap="bootstrap.php"
>
<testsuites>
<testsuite name="databaseTests">
<directory>./Folder0/</directory>
</testsuite>
<testsuite name="shopTests">
<directory>./Folder1/Folder2/Folder3/Folder4/Folder5/</directory>
</testsuite>
<testsuite name="testFolder7">
<directory>./Folder1/Folder2/Folder3/Folder4/Folder5/Folder6-2/Folder7/</directory>
</testsuite>
</testsuites>
<logging>
<log type="coverage-php" target="./Logs/coverage.serialized"/>
<log type="json" target="./Logs/logfile.json"/>
</logging>
<php>
<includePath>.</includePath>
...........more vars const etc ....
</php>
</phpunit>
在bootstrap.php中我只有一些包括其他一些类。
其中一项不起作用的测试:
<?php
class testThatDontWorkTest extends Custom_Tests_DatabaseTestCase {
//in this i just set getConnection()
public function getDataSet() {
return $this->createXMLDataSet(TESTDIR . '/Database/XMLs/dbtests.xml');
}
public static function setUpBeforeClass() {
init(); //some stuff in bootstrap
}
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp() {
parent::setUp();
}
/**
* Tears down the fixture, for example, closes a network connection.
* This method is called after a test is executed.
*/
protected function tearDown() {
parent::tearDown();
}
public function testaddError() {
testThatDontWorkTest::addError();
$queryTable = $this->getConnection()->createQueryTable(
'errors', 'SELECT * FROM errors'
);
$expectedTable = $this->createXmlDataSet(TESTDIR . '/Database
/XMLs/expectedResult.xml')->getTable("errors");
$this->assertTablesEqual($expectedTable, $queryTable);
}
}
我不明白为什么有些测试在Netbeans和其他人没有。
Edit1 :在Netbeans中,我只需右键点击来源 - &gt;测试或直接测试右键单击 - &gt;跑。
来自cmd:
php Lib/phpunit.phar --bootstrap bootstrap.php testThatDontWorkTest ./Folder1/Folder2/Folder3/Folder4/Folder5/Folder6-2/Folder7/testThatDontWorkTest.php
Edit2 :当我正在运行 shopTests testsuit时
phpunit --testsuite shopTests
只有Folder6和Folder7-2中的测试正在运行,Folder7中的测试没有。
我还为Folder7创建了一个测试套件
phpunit --testsuite testFolder7
然后我又来了:
PHPUnit 4.7.7 by Sebastian Bergmann and contributors.
Warning: No whitelist configured for code coverage
Time: 577 ms, Memory: 12.00Mb
No tests executed!
Generating code coverage report in PHP format ... done
Edit3 :当我重命名/重构文件夹Folder7-&gt; Folder8可以运行测试。但是当我重新生成文件夹或文件时,我遇到了同样的问题。任何想法可能是什么问题?