PHPUnit - 'No tests executed' when using configuration file

后端 未结 22 702
故里飘歌
故里飘歌 2021-01-31 00:47

The Problem

To improve my quality of code, I\'ve decided to try to learn how to test my code using Unit Testing instead of my mediocre-at-best testing solutions.

22条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-31 01:38

    I had the same problem after PHPUnit on our virtual machines updated to version 6. Even --debug and --verbose said nothing useful, just "No tests executed". In the end it turned out that classes and namespaces were changed in the new version and it just didn't want to execute the files that contained references to old classes. The fix for me was just to replace in every test case this:

    class MyTestCase extends \PHPUnit_Framework_TestCase {...}
    

    with:

    use PHPUnit\Framework\TestCase;
    
    class MyTestCase extends TestCase {...}
    

提交回复
热议问题