Question

I am using the sausage framework to run parallelized phpunit-based Selenium web driver tests through Sauce Labs. Everything is working well until I want to mark a test as skipped via markTestSkipped(). I have tried this via two methods:

setting markTestSkipped() in the test method itself:

class MyTest
{
    public function setUp()
    {
        //Some set up
        parent::setUp();
    }
    public function testMyTest()
    {
        $this->markTestSkipped('Skipping test');
    }
}

In this case, the test gets skipped, but only after performing setUp, which performs a lot of unnecessary work for a skipped test. To top it off, phpunit does not track the test as skipped -- in fact it doesn't track the test at all. I get the following output:

Running phpunit in 4 processes with <PATH_TO>/vendor/bin/phpunit

Time: <num> seconds, Memory: <mem used>

OK (0 tests, 0 assertions)

The other method is by setting markTestSkipped() in the setUp method:

class MyTest
{
    public function setUp()
    {
        if (!shouldRunTest()) {
            $this->markTestSkipped('Skipping test');
        } else {
            parent::setUp();
        }
    }
    protected function shouldRunTest()
    {
        $shouldrun = //some checks to see if test should be run
        return $shouldrun;
    }
    public function testMyTest()
    {
        //run the test
    }
}

In this case, setUp is skipped, but the test still fails to track the tests as skipped. phpunit still returns the above output. Any ideas why phpunit is not tracking my skipped test when they are executed in this fashion?

Was it helpful?

Solution

It looks like, at the moment, there is no support for logging markTestSkipped() and markTestIncomplete() results in PHPunit when using paratest. More accurately, PHPunit won't log tests which call markTestSkipped() or markTestIncomplete() if called with arguments['junitLogfile'] set -- and paratest calls PHPunit with a junitLogfile.

For more info, see: https://github.com/brianium/paratest/issues/60

I suppose I can hack away at either phpunit or paratest...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top