Cspray\Labrador\AsyncUnit\Attribute\BeforeAll
Cspray\Labrador\AsyncUnit\Attribute\BeforeEach
Cspray\Labrador\AsyncUnit\Attribute\AfterEach
Cspray\Labrador\AsyncUnit\Attribute\AfterAll
Cspray\Labrador\AsyncUnit\Attribute\BeforeEachTest
*Cspray\Labrador\AsyncUnit\Attribute\AfterEachTest
*TestSuite
. Defining them on a TestCase
is currently ignored and in future versions will result in a compilation error. All other attributes can be defined on methods belonging to either a TestSuite
or a TestCase
.TestSuite
your hook lifecycle will have 2 "effective" orders. The order of hooks for the explicit TestSuite
is followed for all suites, even the ImplicitTestSuite
, however the implicit suite will never have a hook defined and thus is effectively always skipping the TestSuite
specific hooks.ImplicitTestSuite
then the hook order is straightforward and, for the most part, aligns with what you'd be used to with PHPUnit or other testing frameworks. The following hook lifecycle applies to each TestCase
.BeforeAll
methods defined are executed when a given TestCase
has started processing. These methods will only be invoked 1 time per TestCase
, even if multiple tests are defined. This should be a static class method.BeforeEach
methods defined on the TestCase
are executed when a given test has started processing. These methods will be invoked 1 time, with a fresh TestCase
instance, for every single test.AfterEach
methods defined on the TestCase
are executed when a given test has finished processing. These methods will be invoked 1 time, with a fresh TestCase
instance, for every single test.AfterAll
methods defined on the TestCase
are executed when all tests are finished executing for the given TestCase
. These methods will only be invoked 1 time per TestCase
, even if multiple tests are defined. This should be a static class method.TestSuite
then your hook order starts to become more advanced, and with advance functionality comes an increase in complexity. It is important before you start defining your own hooks on TestSuite
you understand how they operate and interact with your tests. The following hook lifecycle applies to each TestSuite
BeforeAll
methods defined on the TestSuite
are executed when a given suite has started processing. These methods will only be invoked 1 timer per TestSuite
. Only one TestSuite
instance will be created for each suite processed so there is no need for this to be a static method.BeforeEach
methods defined on the TestSuite
are executed before a given TestCase
has started processing. These methods will be invoked 1 time for every TestCase
associated to the suite.BeforeAll
methods defined on the TestCase
are executed. Follows the same rules for the implicit use case.BeforeEachTest
methods defined on the TestSuite
are executed before a given test has started. These methods will be invoked 1 time for every single test.BeforeEach
methods defined on the TestCase
are executed. Follows the same rules for the implicit use case.AfterEach
methods defined on the TestCase
are executed. Follows the same rules for the implicit use case.AfterEachTest
methods defined on the TestSuite
are executed after a given test has finished. These methods will be invoked 1 time for every single test.AfterAll
methods defined on the TestCase
are executed . Follows the same rules for the implicit use case.AfterEach
methods defined on the TestSuite
are executed after a given TestCase
has finished processing. These methods will be invoked 1 time for every TestCase
associated to the suite.AfterAll
methods defined on the TestSuite
are executed when a given suite has finished processing. These methods will only be invoked 1 time per TestSuite
. Only one TestSuite
instance will be created for each suite processed so there is no need for this to be a static method.