我正在使用Codeception进行Laravel 4 PHP应用程序的单元,功能和验收测试.
我的单元测试看起来如下:
use Codeception\Util\Stub; class ExampleTest extends \Codeception\TestCase\Test { public function testExample() { $example = true; $this->assertSame($example, true); } }
我的功能测试看起来像这样:
use \TestGuy; class ExampleCest { public function example(TestGuy $I) { $I->amOnPage('/auth/login'); $I->see('Sign in'); } }
但我也想在我的功能测试中使用PHPUnit断言方法.但是当我尝试时,我得到了这个错误:
调用未定义的方法ExampleCest :: assertSame()
如何在Codeception功能测试中使用PHP断言方法?
自Codeception 2.1(而非2.0)以来,您可以像使用其他断言一样使用它:
$I->assertSame($expected, $actual, $message);
但是不要忘记Asserts
在配置中启用模块 - 例如:
class_name: UnitTester modules: enabled: [ Asserts ]
请注意:升级到2.1时可能需要更改配置 - 请参阅升级说明:http://codeception.com/06-19-2015/codeception-2.1-rc.html
\PHPUnit_Framework_Assert::assertSame()