對於集成測試,我想重新使用測試結果。依賴性通過註釋來定義。對於要執行的依賴性測試,以前測試的結果需要可用。因此,測試需要按照固定順序執行。否則,跳過依賴於其他測試的測試。爲了確保測試按照固定順序執行,測試套件已經定義。仍然會跳過依賴關係的測試。這是爲什麼?phpunit跳過不同測試用例之間的依賴性測試
ATest.php:
<?php
use PHPUnit\Framework\TestCase;
class ATest extends TestCase
{
public function testA()
{
self::assertTrue(true);
return $this;
}
}
BTest.php:
<?php
use PHPUnit\Framework\TestCase;
class BTest extends TestCase
{
/**
* @depends ATest::testA()
*/
public function testB($a)
{
self::assertTrue(true);
}
}
phpunit.xml:
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
verbose="true"
>
<testsuites>
<testsuite name="dependency">
<file>ATest.php</file>
<file>BTest.php</file>
</testsuite>
</testsuites>
</phpunit>
phpunit --testsuite dependency
PHPUnit 5.5.7作者Sebastian Bergmann和 貢獻者。
運行時:與Xdebug的2.5.4 PHP 7.1.5配置: /phpunit.xml
.S 2 /2(100%)
時間:49毫秒,內存:4.00MB
有1跳過測試:
1)BTEST :: TESTB該測試依賴於 「ATEST ::種皮()」 通過。
好的,但不完整,跳過或有風險的測試!測試:1,斷言:1, 跳過:1.