codeception 单元测试仅针对公共函数 testMe 运行


codeception unit tests run only for public function testMe

我创建了一个codeception unit test:

<?php

use Something'SiteResultsHolder;
class ResultHolderTest extends 'Codeception'TestCase'Test
{
   /**
    * @var 'UnitTester
    */
    protected $tester;
    protected function _before()
    {
    }
    protected function _after()
    {
    }
    // tests
    public function testMe()
    {
        //this test run
    }
    public function checkLimit() {
       //this test doesn't run
    }
}

我在终端中称之为:

codecept run unit

但唯一的测试调用是 --> testMe并且它不运行 --> 检查限制

而且它们都是公开的。

当我进行验收测试时,所有公共方法都是不同的测试,但在这里它似乎不起作用。

如何在那里添加测试? 那会叫?

根据 PhpUnit 4.2 文档 (https://phpunit.de/manual/current/en/writing-tests-for-phpunit.html(:

测试是名为 test* 的公共方法。

或者,您可以使用方法的文档块中的@test注释将其标记为测试方法。

'Codeception'TestCase'Test扩展'Codeception'TestCase,扩展'PHPUnit_Framework_TestCase

因此,您实际上是在使用PHPUnit。您可以使用 phpunit 文档作为参考 (https://phpunit.de/manual/current/en/index.html(。

在您的情况下:

public function testCheckLimit() {
}

/**
 * @test
 */
public function checkLimit() {
}

应该工作