简体   繁体   中英

depends in phpunit doesn't seem to be working

Maybe it's just me but @depends doesn't seem to be working as I'd expect it to. My code:

<?php
use PHPUnit\Framework\TestCase;

class MyTest extends TestCase
{
    /*
     * @depends testFunc1
     */
    public function testFunc2()
    {
        exit('TEST FUNC 2 called');
    }

    public function testFunc1()
    {
        exit('TEST FUNC 1 called');
    }
}

When I do phpunit MyTest.php I'd expect to see TEST FUNC 1 called but instead I see TEST FUNC 2 called . As is it seems to just be running the tests in the order they appear in the script, regardless of the @depends attribute, which really begs the question: what does @depends actually do?

I'm running PHPUnit 5.7.20.

您需要使用/**而不是/*来启动docblock。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM