codeception/assert-throws
最新稳定版本:1.5.0
Composer 安装命令:
composer require codeception/assert-throws
包简介
Assert exception was thrown without stopping a test
README 文档
README
Handle exceptions inside a test without a stop! Works with PHPUnit and Codeception.
Installation
composer require "codeception/assert-throws" --dev
Include AssertThrows trait it to a TestCase:
<?php class MyTest extends PHPUnit\Framework\TestCase { use Codeception\AssertThrows; //... }
Usage
Catch exception thrown inside a code block.
<?php $this->assertThrows(NotFoundException::class, function() { $this->userController->show(99); }); // alternatively $this->assertThrows(new NotFoundException(), function() { $this->userController->show(99); }); // you can also assert that an exception is not throw $this->assertDoesNotThrow(NotFoundException::class, function() { $this->userController->show(99); });
You can optionally test the exception message:
<?php $this->assertThrowsWithMessage( NotFoundException::class, 'my error message', function() { throw new NotFoundException('my error message'); } );
License
Codeception AssertThrows is open-sourced software licensed under the MIT License.
© Codeception PHP Testing Framework
统计信息
- 总下载量: 1.71M
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 19
- 点击次数: 1
- 依赖项目数: 39
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-01-09