Codeception / PHPUnit Assert :: isTrue传递为false

时间:2018-02-21 12:13:17

标签: codeception

以下测试如何通过,这有意义吗?

<?php
use \Codeception\Util\Debug;
use \PHPUnit\Framework\Assert;

class TrackingCest
{
    // tests
    public function tryToTest(AcceptanceTester $I)
    {
        Debug::debug("I am really here!");
        Assert::isTrue(false);
    }
}

2 个答案:

答案 0 :(得分:2)

enricog is right, you need to use

$I->assertTrue(false);

But you will need to enable the Asserts module in your configuration, in acceptance.suite.yml:

classname: AcceptanceTester
modules: 
    enabled:
        - Asserts

Besides that, there is no need to use the use statements at the top. Your test could look like this:

<?php

class TrackingCest
{
    // tests
    public function tryToTest(AcceptanceTester $I)
    {
        codecept_debug("I am really here!");
        $I->assertTrue(false);
    }
}

答案 1 :(得分:0)

你实际上没有检查任何东西。

请参阅PHPUnits Assert::isTrue方法的实现,它只返回一个新的IsTrue实例:

PHPUnit::Assert

要使用代码检查检查true,您应该使用注入的 Tester 上的方法:

$I->assertTrue(false);
相关问题