Skip to content
...

All Attributes

Testo uses PHP attributes to configure tests, lifecycle hooks, data providers, and more. This page lists all available attributes grouped by plugin. Click any attribute name for full documentation with parameters and examples.

AttributePluginDescription
#[AfterClass]#[AfterClass(int $priority = 0)]Runs a method once after all tests in the class. Suitable for cleanup.LifecycleRuns a method once after all tests in the class. Suitable for cleanup.
#[AfterTest]#[AfterTest(int $priority = 0)]Runs a method after each test in the class.LifecycleRuns a method after each test in the class.
#[BeforeClass]#[BeforeClass(int $priority = 0)]Runs a method once before all tests in the class. Suitable for expensive setup.LifecycleRuns a method once before all tests in the class. Suitable for expensive setup.
#[BeforeTest]#[BeforeTest(int $priority = 0)]Runs a method before each test in the class.LifecycleRuns a method before each test in the class.
#[Bench]#[Bench(array $callables, array $arguments = [], int $warmup = 1, int $calls = 1_000, int $iterations = 10)]Declares a benchmark comparing the method's performance against alternative implementations.BenchDeclares a benchmark comparing the method's performance against alternative implementations.
#[Covers]#[Covers(string $classOrFunction, ?string $method = null)]Restricts which source code counts toward coverage for this test.CodecovRestricts which source code counts toward coverage for this test.
#[CoversNothing]#[CoversNothing]Excludes a test from coverage statistics.CodecovExcludes a test from coverage statistics.
#[DataCross]#[DataCross(DataProviderAttribute ...$providers)]Creates all possible combinations from providers (cartesian product).DataCreates all possible combinations from providers (cartesian product).
#[DataProvider]#[DataProvider(callable|string $provider)]Provides data for a parameterized test from a method or callable.DataProvides data for a parameterized test from a method or callable.
#[DataSet]#[DataSet(array $arguments, ?string $name = null)]Declares a set of arguments for a parameterized test. Can be used multiple times — each attribute creates a separate test run.DataDeclares a set of arguments for a parameterized test. Can be used multiple times — each attribute creates a separate test run.
#[DataUnion]#[DataUnion(DataProviderAttribute ...$providers)]Merges data from multiple providers into a single sequential set.DataMerges data from multiple providers into a single sequential set.
#[DataZip]#[DataZip(DataProviderAttribute ...$providers)]Pairs up providers element by element.DataPairs up providers element by element.
#[Retry]#[Retry(int $maxAttempts = 3, bool $markFlaky = true)]Declares a retry policy for a test on failure.RetryDeclares a retry policy for a test on failure.
#[Test]#[Test()]Explicitly marks a method, function, or class as a test.TestExplicitly marks a method, function, or class as a test.
#[TestInline]#[TestInline(array $arguments, mixed $result = null)]Declares an inline test on a method or function.InlineDeclares an inline test on a method or function.