Test Suites
Organize TestCases and expose functionality for all of the associated TestCases in one place. A fundamental concept for integration testing capabilities provided by AsyncUnit!
Defining a TestSuite
<?php
use Cspray\Labrador\AsyncUnit\TestSuite;
use Cspray\Labrador\AsyncUnit\Attribute\BeforeAll;
use Cspray\Labrador\AsyncUnit\Attribute\BeforeEachTest;
use Generator;
class HeavyTestSuite extends TestSuite {
#[BeforeAll]
public function createHeavy() : Generator {
$heavy = yield HeavyFactory::create();
$this->set('heavy', $heavy);
}
#[BeforeEachTest]
public function runHeavy() : Generator {
yield $this-get('heavy')->doSomethingHeavy();
}
#[AfterEachTest]
public function freeHeavy() : Generator {
yield $this->get('heavy')->free();
$this->set('heavy', null);
}
}The BeforeAll Hook
The BeforeEachTest Hook
The AfterEachTest Hook
Declaring a TestSuite
Making a TestSuite the default
Declare on each TestCase
There's always a TestSuite
Understand the Hook lifecycle
HooksLast updated
Was this helpful?