Yeah, the count of assertions is not shown, but also in Pest the Expectation API is more popular and you can chain expectations so I don't think that the reason of not showing the number is because pest itself expects one assertion per test. But also IMO it is more important how many tests you have and that those tests cover your code than how many assertions you've had in a test.
Jan 15, 2022
1
Level 2
Unlike PHPUnit, Pest PHP doesn't show number of assertions
Consider code snippets below:
PHPUnit
<?php declare(strict_types=1);
use PHPUnit\Framework\TestCase;
final class StackTest extends TestCase
{
public function testPushAndPop(): void
{
$stack = [];
$this->assertSame(0, count($stack));
array_push($stack, 'foo');
$this->assertSame('foo', $stack[count($stack)-1]);
$this->assertSame(1, count($stack));
$this->assertSame('foo', array_pop($stack));
$this->assertSame(0, count($stack));
}
}
Pest PHP
<?php
test('push and pop', function () {
{
$stack = [];
$this->assertSame(0, count($stack));
array_push($stack, 'foo');
$this->assertSame('foo', $stack[count($stack)-1]);
$this->assertSame(1, count($stack));
$this->assertSame('foo', array_pop($stack));
$this->assertSame(0, count($stack));
}
When the test runs PHPUnit unit will show the number of assertions in the test but pest will just show the test description. Does Pest expect one to have ONE assertion per test? Just curious.
Level 73
1 like
Please or to participate in this conversation.