Feature #262

Always runs all dependent tests by @depends.

Added by Atsuhiro KUBO over 2 years ago. Updated almost 2 years ago.

Status:Feedback Start date:02/02/2011
Priority:Normal Due date:
Assignee:Atsuhiro KUBO % Done:

0%

Category:PHPUnit
Target version:-
Tags:#collecting #phpunit
Votes: 0

Description

The following class has two tests the pass() and skip() methods. The skip() method is run only the pass() method is passed.

 1class Stagehand_TestRunner_PHPUnitDependsTest extends PHPUnit_Framework_TestCase
 2{
 3    /**
 4     * @test
 5     */
 6    public function pass()
 7    {
 8        $this->assertTrue(false);
 9    }
10
11    /**
12     * @test
13     * @depends pass
14     */
15    public function skip()
16    {
17        $this->assertTrue(true);
18    }
19}

Here you can run only the skip() method by the -m option.

 1$ php53 bin/phpunitrunner -p examples/prepare.php -m skip examples/Stagehand/TestRunner/PHPUnitDependsTest.php 
 2PHPUnit 3.5.10 by Sebastian Bergmann.
 3
 4S
 5
 6Time: 0 seconds, Memory: 3.25Mb
 7
 8OK, but incomplete or skipped tests!
 9Tests: 0, Assertions: 0, Skipped: 1.

As a result, the skip() method was skipped even though the pass() method was not run. Is this expected behavior?


Resources


Related issues

related to Stagehand_TestRunner - Defect #288: The excluded tests by the <groups> element are contained ... Closed 05/26/2011

History

Updated by Atsuhiro KUBO over 2 years ago

  • Status changed from New to Assigned

Updated by Atsuhiro KUBO over 2 years ago

  • Status changed from Assigned to Feedback
  • Target version deleted (2.16.0)

PHPUnit Manual says:

PHPUnit does not change the order in which tests are executed, you have to ensure that the dependencies of a test can actually be met before the test is run.

I think this is good policy for handling dependencies between tests. Automated dependency resolution by Stagehand_TestRunner has the following issues:

  • Stagehand_TestRunner's approach to test collection is file-based, not class-based. If a dependent test defined in an external file, how Stagehand_TestRunner can load the file?
  • If the dependency graph for a test is large, there is not much difference between running all dependent tests and all the tests.

Also available in: Atom PDF