elliotchance / concise

✅ Concise is test framework for using plain English and minimal code, built on PHPUnit.
MIT License
45 stars 3 forks source link

Allow verify() #216

Closed elliotchance closed 9 years ago

elliotchance commented 9 years ago

Verify is supported by some other testing frameworks. It allows an assertion that does not stop the execution of the test.

$this->verify(123, equals, 456);
// Code can still continue, but the whole test will fail if at least one verification fails.
elliotchance commented 9 years ago

This is most useful when testing many properties of an object where a single failure would not normally break execution:

public function testVerify()
{
    $data = $this->fetchData();

    // if its not an array, we must stop here
    $this->assert($data, is_an_array); 

    // failures here do no break execution and we can see all the failures in the output
    $this->verify($data, has_key, 'total', with_value, 1.23);
    $this->verify($data, has_key, 'lines');

    // $data['lines'] must be an array
    $this->assert($data['lines'], is_an_array);

    $this->verify(count($data['lines']), equals, 3);
}