Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to skip tests in PHPunit?

Tags:

php

phpunit

I am using phpunit in connection with jenkins, and I want to skip certain tests by setting the configuration in the XML file phpunit.xml

I know that I can use on the command line:

phpunit --filter testStuffThatBrokeAndIOnlyWantToRunThatOneSingleTest

how do I translate that to the XML file since the <filters> tag is only for code-coverage?

I would like to run all tests apart from testStuffThatAlwaysBreaks

like image 549
filype Avatar asked Apr 20 '12 01:04

filype


People also ask

How do I run a PHPUnit test?

How to Run Tests in PHPUnit. You can run all the tests in a directory using the PHPUnit binary installed in your vendor folder. You can also run a single test by providing the path to the test file. You use the --verbose flag to get more information on the test status.

What is assertion in PHPUnit?

The assertion methods are declared static and can be invoked from any context using PHPUnit\Framework\Assert::assertTrue() , for instance, or using $this->assertTrue() or self::assertTrue() , for instance, in a class that extends PHPUnit\Framework\TestCase .

What is mock PHPUnit?

Likewise, PHPUnit mock object is a simulated object that performs the behavior of a part of the application that is required in the unit test. The developers control the mock object by defining the pre-computed results on the actions.

What is PHPUnit result cache?

This file helps PHPUnit remember which tests previously failed, which can speed up your testing flow if you only re-run failed tests during development.


1 Answers

The fastest and easiest way to skip tests that are either broken or you need to continue working on later is to just add the following to the top of your individual unit test:

$this->markTestSkipped('must be revisited.'); 
like image 80
jsteinmann Avatar answered Sep 18 '22 18:09

jsteinmann