PHPUnit - 'No tests executed' when using configuration file

后端 未结 22 692
故里飘歌
故里飘歌 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:25

    Your XML file is fine as it is. However, you have to make sure that the PHP files in your tests/ folder are named as follows:

    tests/Test.php <--- Note the uppercase "T"
    tests/userTest.php
    tests/fooBarTest.php
    etc.

    The filenames must end with "Test.php". This is what PHPUnit is looking for within directories.

    Furthermore, every test method must have a name that starts with "test":

    public function testFooBar()
    {
        // Your test code
    }
    

    Hope that helps!

提交回复
热议问题