PHPUnit and extended class - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: PHPUnit and extended class (/showthread.php?tid=78843) |
PHPUnit and extended class - WebboyFR - 03-17-2021 Hello, I am testing PHPunit with CI4. I run a test on HTTP testing (to test routes), so my classe extends "FeatureTestCase" And when I run my test, PHPUNIT says : Code: 1) Warning This is my test class : PHP Code: <?php I just want to "exclude" the parent class from the code coverage, but I search everywhere, I didn't find. I think it's more touchy because it's not a file but a namespace... Please, how can I exclude the framework's class from my test ? Thanks RE: PHPUnit and extended class - kenjis - 03-17-2021 (03-17-2021, 11:30 AM)WebboyFR Wrote: Please, how can I exclude the framework's class from my test ? By default the framework's test classes are excluded. How do you include it? Here is CI 4.1.1 test results. No "CodeIgniter\Test\FeatureTestCase". Code: $ vendor/bin/phpunit --debug RE: PHPUnit and extended class - WebboyFR - 03-18-2021 Thanks. I didn't install "code coverage driver" Code: PHPUnit 9.5.3 by Sebastian Bergmann and contributors. It could be that ? RE: PHPUnit and extended class - WebboyFR - 03-18-2021 After installed xdebug, I got this : Code: ./vendor/bin/phpunit --debug What is that in my result ? Code: Test 'Warning' started It seems like I made "Warning" test... Maybe a namespace problem ? I think I've missed something... This is the top of my Test Class file : PHP Code: <?php RE: PHPUnit and extended class - kenjis - 03-18-2021 Can you show your phpunit.xml.dist? (03-18-2021, 01:55 AM)WebboyFR Wrote: What is that in my result ? You have "Warning" test case. Do you have it? RE: PHPUnit and extended class - WebboyFR - 03-19-2021 phpunit.xml.dist : Code: <?xml version="1.0" encoding="UTF-8"?> And no, I don't wrote any "Warning" test case. RE: PHPUnit and extended class - kenjis - 03-19-2021 Code: <testsuite name="App"> Your phpunit.xml.dist seems to be okay. I don't know what's wrong. <directory>./tests</directory> It means the following: <directory suffix="Test.php">./tests</directory> You need to name ***Test.php for test case files. RE: PHPUnit and extended class - WebboyFR - 03-19-2021 Thanks for the look kenjis. Yes I tested to exclude the FeatureTestCase file in phpunit.xml, but I think its more a namespace problem or an autoinstanciation of the parent class with extends. Maybe the problem is in these lines ? PHP Code: public function setUp(): void RE: PHPUnit and extended class - kenjis - 03-19-2021 I think the setUp() and tearDown() are no problems. But you can remove them, because you don't add any code to the methods. Code: Test 'App\Libraries\FooTest::testFooNotBar' started So FooTest is okay, but why TestUrlExists and Warning? Do you have `phpunit.xml`? |