【问题标题】:PHPunit 9.23 PHP 7.4.7 Warning no test found in classPHPunit 9.23 PHP 7.4.7 警告在类中找不到测试
【发布时间】:2020-10-23 21:33:23
【问题描述】:

我正在尝试使用 PHPUNit 编写一些测试,但是当我尝试运行 .\vendor\bin\phpunit 时无法识别测试。 这是我的测试类的示例

use \App\Controllers\city_controller;
use PHPUnit\Framework\TestCase;

class city_controllerTest extends TestCase
{
    /**
     * @test
     */
     public function test_AddCity(){
      $this->assertTrue(true);
     }
}

我总是收到“课堂上没有发现测试的警告”。 谁能帮我? 非常感谢。

【问题讨论】:

    标签: phpunit


    【解决方案1】:

    在文档中,方法名称必须以“test”开头。

    我会将test_AddCity() 重命名为testAddCity()

    还有你的班级TestCityController

    希望这对你和我一样有效!

    【讨论】:

      猜你喜欢
      • 2015-02-20
      • 1970-01-01
      • 2017-06-08
      • 1970-01-01
      • 2016-10-17
      • 1970-01-01
      • 1970-01-01
      • 2017-09-29
      • 2017-08-14
      相关资源
      最近更新 更多