您当前的位置: 首页 > 慢生活 > 程序人生 网站首页程序人生
phpunit断言-assertLessThanOrEqual
发布时间:2021-10-04 23:25:05编辑:雪饮阅读()
assertLessThanOrEqual断言主要是断言实际值小于或等于预期值。
LessThanOrEqualTest.php:
<?php declare(strict_types=1);
use PHPUnit\Framework\TestCase;
final class LessThanOrEqualTest extends TestCase
{
public function testFailure(): void
{
$this->assertLessThanOrEqual(1, 2);
}
public function testTwo(): void
{
$this->assertLessThanOrEqual(1, 0);
}
public function testThree(): void
{
$this->assertLessThanOrEqual(1, 1);
}
}
use PHPUnit\Framework\TestCase;
final class LessThanOrEqualTest extends TestCase
{
public function testFailure(): void
{
$this->assertLessThanOrEqual(1, 2);
}
public function testTwo(): void
{
$this->assertLessThanOrEqual(1, 0);
}
public function testThree(): void
{
$this->assertLessThanOrEqual(1, 1);
}
}
运行效果如:
C:\Users\Administrator>D:\phpstudy_pro\Extensions\php\php7.4.3nts\php.exe C:\Users\Administrator\PhpstormProjects\untitled\vendor\phpunit\phpunit\phpunit -c C:\Users\Administrator\PhpstormProjects\untitled\organizing\phpunit.xml C:\Users\Administrator\PhpstormProjects\untitled\organizing\tests\LessThanOrEqualTest.php
PHPUnit 9.5.8 by Sebastian Bergmann and contributors.
F.. 3 / 3 (100%)
Time: 00:00.012, Memory: 6.00 MB
There was 1 failure:
1) LessThanOrEqualTest::testFailure
Failed asserting that 2 is equal to 1 or is less than 1.
C:\Users\Administrator\PhpstormProjects\untitled\organizing\tests\LessThanOrEqualTest.php:8
FAILURES!
Tests: 3, Assertions: 6, Failures: 1.
关键字词:phpunit,assertLessThanOrEqual