Content-Length: 280039 | pFad | http://github.com/Codeception/AssertThrows

E5 GitHub - Codeception/AssertThrows: Assert exception handling without stopping a test. For PHPUnit 6+
Skip to content

Codeception/AssertThrows

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AssertThrows

Handle exceptions inside a test without a stop! Works with PHPUnit and Codeception.

Actions Status Latest Stable Version Total Downloads License

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

About

Assert exception handling without stopping a test. For PHPUnit 6+

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 11

Languages









ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/Codeception/AssertThrows

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy