Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mark a PHPUnit test class as to be ignored

Tags:

I have written an abstract test case class that is to be extended by concrete test case classes.

It extends from the PHPUnit_TestCase.

Is there a method or annotation that signals Phpunit to not execute this abstract test (but does not mark it as skipped or incomplete)?

Right now Phpunit runs the abstract test class as well and then reports an error that it can not instantiate it - which is by language: An abstract class can not be instantiated.

like image 839
hakre Avatar asked May 09 '11 08:05

hakre


People also ask

What is PHPUnit testing?

PHPUnit is a unit testing framework for the PHP programming language. It is an instance of the xUnit architecture for unit testing frameworks that originated with SUnit and became popular with JUnit. PHPUnit was created by Sebastian Bergmann and its development is hosted on GitHub.

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 assertEquals() function is a builtin function in PHPUnit and is used to assert whether the actual obtained value is equals to expected value or not. This assertion will return true in the case if the expected value is the same as the actual value else returns false.

What are PHPUnit fixtures?

Fixtures of a test involve writing a code to set the world up in a known state, and after the test, return it back to its original state. When testing array operations in PHPUnit, the array stored in the `$stack` variable is simply the fixture.


2 Answers

Just add the skip on the setUp():

protected function setUp() {     $this->markTestIncomplete(); } 
like image 153
jhvaras Avatar answered Sep 28 '22 10:09

jhvaras


If it is named FooTest rename it to FooTestCase.

like image 44
David Harkness Avatar answered Sep 28 '22 10:09

David Harkness