Student C Over titrated the Php Solution but Ignored It and Continued

3 Answers 3

Just add the skip on the setUp():

                protected function setUp() {     $this->markTestIncomplete(); }                              

answered Sep 16, 2016 at 11:09

jhvaras's user avatar

3

  • That would mark all extending tests as incomplete, exactly not what I asked about (just in case that was not clear).

    Sep 16, 2016 at 11:12

  • protected function setUp() :void { $this->markTestIncomplete(); }

    Dec 22, 2020 at 14:23

  • Is off-topic of original question, but in case you reach here looking for skipping temporarily, you can also use $this->markTestSkipped('Work in progress'); to skip the test when you want to temporarily skip this class while you are refactoring other sections that this class test requires.

    Sep 8 at 23:19

If it is named FooTest rename it to FooTestCase.

answered May 9, 2011 at 8:31

David Harkness's user avatar

7

  • I added Case to the abstract class name and I now only get the error when executing that test directly. Makes sense. Executing the whole directory ignores it. Thanks!

    May 9, 2011 at 9:30

  • @hakre - Yes, if you give PHPUnit the name of a file it doesn't do any scanning on its own.

    May 10, 2011 at 0:31

  • @SS Renaming the class itself. If you don't tell PHPUnit to run a specific file, it loads all files named *Test.php and then instantiates all classes named *Test. Make sure your abstract test cases that must be extended do not end in Test.

    Sep 21, 2016 at 22:27

  • Yes, I see, I have bigger issue phpunit somehow running all files in /tests folder even if I completely delete innerXml of <testsuite> node as I found out later today stackoverflow.com/questions/39616107/…

    Sep 21, 2016 at 22:37

  • @NinoŠkopac Declare the class as abstract, then it should work. Simply renaming didn't work for me too.

    Feb 19, 2018 at 9:56

Assuming you want to exclude the file name TestCase.php. As in my case I use this class as an abstract to all my test classes which itself extends PHPUnit_Framework_TestCase.

Solution: add this to your phpunit.xml

                <testsuites>     <testsuite name="BLABLA">         <directory suffix=".php">./tests</directory>         <exclude>./tests/TestCase.php</exclude>     </testsuite> </testsuites>                              

My TestCase.php example:

                <?php namespace Foo\Bar\Tests;  use Mockery as M; use PHPUnit_Framework_TestCase as PHPUnit;  /**  * Class TestCase is the Parent test class that every test class must extend from.  */ class TestCase extends PHPUnit {      public function __construct()     {         parent::__construct();     }  //...                              

answered May 24, 2015 at 0:17

Mahmoud Zalt's user avatar

3

  • When it's an abstract class and it's named TestCase.php , you don't need to exclude it in the XML. That code is superfluous, therefore cruft and should be removed from the XML file. I'm sorry if that wasn't clear from the title of the question only, but the question itself should make clear what this was about. You answer a different question here.

    May 25, 2015 at 7:58

  • I though this is the exact thing you need as your questions Mark a PHPUnit test class as to be ignored is what appeared first on google when I was searching for How to ignore test class in PHPUnit. What I really want is to ignore the test class that all other test classes extend from. Because if I don't ignore it I got the error saying no tests in this class which is true since it just hosts common functions for all the test classes. The right solution that I found is to ignore that class from running form the phpunit.xml

    May 25, 2015 at 17:29

  • The title might signal that, yes, but the class is a class of type TestCase (abstract class) and not a generic test class where the tests are written in. I don't say your answer is wrong just wanted to point out the little difference as you answered quite late and then sometimes the answers are a little disconnected. You didin't wrote any wrong information in your answer or something similar. Just wanted to add some context.

    May 26, 2015 at 5:49

bingastive.blogspot.com

Source: https://stackoverflow.com/questions/5934347/mark-a-phpunit-test-class-as-to-be-ignored

0 Response to "Student C Over titrated the Php Solution but Ignored It and Continued"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel