phpUnit the assertion methods assertTrue

assertTrue

assertTrue(bool $condition[, string $message = ''])
<?php
require_once dirname(dirname(__FILE__)) . '\vendor\autoload.php';

use PHPUnit\Framework\TestCase;

class MyClassTest extends TestCase{

    /**
     * @test
     */
    public function one()
    {
        $this->assertTrue(false, '当条件为不为真报这条错误信息');
    }

    /**
     * @test
     * @depends one
     */
    public function two()
    {

    }

}
PHPUnit 6.5.3 by Sebastian Bergmann and contributors.

Runtime:       PHP 7.2.1 with Xdebug 2.7.0

FS                                                                  2 / 2 (100%)

Time: 679 ms, Memory: 8.00MB

There was 1 failure:

1) MyClassTest::one
当条件为不为真报这条错误信息
Failed asserting that false is true.

D:\yanjing\workspace\study_test\php\MyClass.php:15

--

There was 1 skipped test:

1) MyClassTest::two
This test depends on "MyClassTest::one" to pass.

FAILURES!
Tests: 2, Assertions: 1, Failures: 1, Skipped: 1.

Guess you like

Origin www.cnblogs.com/zxcv123/p/12517835.html