For a integration test I want to reuse test results. A dependency is defined via annotations. For the depending tests to be executed the result from previous tests needs to be available. Therefore the tests need to be executed in a fixed order. Otherwise tests which depend on other tests are skipped. To make sure the tests are executed in a fixed order, a test suite has been defined. Still the test with the dependency is skipped. Why is that?
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 by Sebastian Bergmann and contributors.
Runtime: PHP 7.1.5 with Xdebug 2.5.4 Configuration: /phpunit.xml
.S 2 / 2 (100%)
Time: 49 ms, Memory: 4.00MB
There was 1 skipped test:
1) BTest::testB This test depends on "ATest::testA()" to pass.
OK, but incomplete, skipped, or risky tests! Tests: 1, Assertions: 1, Skipped: 1.