您当前的位置: 首页 > 慢生活 > 程序人生 网站首页程序人生
phpunit断言-assertDirectoryExists
发布时间:2021-10-01 22:06:30编辑:雪饮阅读()
assertDirectoryExists断言用来断言一个目录是否存在,若这个目录存在则断言成功,否则断言失败。
DirectoryExistsTest.php:
<?php declare(strict_types=1);
use PHPUnit\Framework\TestCase;
final class DirectoryExistsTest extends TestCase
{
public function testFailure(): void
{
$this->assertDirectoryExists('D:\phpstudy_pro\Extensions\php\php7.3.4');
}
public function testSuccess(): void
{
$this->assertDirectoryExists('D:\phpstudy_pro\Extensions\php\php7.3.4nts');
}
}
use PHPUnit\Framework\TestCase;
final class DirectoryExistsTest extends TestCase
{
public function testFailure(): void
{
$this->assertDirectoryExists('D:\phpstudy_pro\Extensions\php\php7.3.4');
}
public function testSuccess(): void
{
$this->assertDirectoryExists('D:\phpstudy_pro\Extensions\php\php7.3.4nts');
}
}
运行结果:
C:\Users\Administrator>D:\phpstudy_pro\Extensions\php\php7.3.4nts\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\DirectoryExistsTest.php
PHPUnit 9.5.8 by Sebastian Bergmann and contributors.
F. 2 / 2 (100%)
Time: 00:00.008, Memory: 4.00 MB
There was 1 failure:
1) DirectoryExistsTest::testFailure
Failed asserting that directory "D:\phpstudy_pro\Extensions\php\php7.3.4" exists.
C:\Users\Administrator\PhpstormProjects\untitled\organizing\tests\DirectoryExistsTest.php:8
FAILURES!
Tests: 2, Assertions: 2, Failures: 1.
关键字词:phpunit,assertDirectoryExists
相关文章
- phpunit断言assertCount
- phpunit断言assertContainsOnlyInstancesOf
- phpunit断言-assertContainsOnly
- phpunit断言assertStringContainsStringIgnoringCase
- phpunit断言-assertStringContainsString
- phpunit断言-assertContains
- phpunit断言assertClassHasStaticAttribute
- phpunit断言assertClassHasAttribute
- phpunit断言-assertArrayHasKey
- phpunit指明应当不覆盖任何方法的测试-@coversNothing