我创建了一个代码单元测试:
<?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
但唯一的测试电话是 - &gt;考验我 并且它没有运行 - &gt; checkLimit
他们都是公开的。
当我进行验收测试时,所有公共方法都是不同的测试,但在这里它似乎不起作用。
如何在那里添加测试?那将被称为?
答案 0 :(得分:5)
根据PhpUnit 4.2文档(https://phpunit.de/manual/current/en/writing-tests-for-phpunit.html):
测试是公共方法,名为test *。
或者,您可以在方法的docblock中使用@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() {
}
应该有效