From c7d34ce2c4dca5230c62cee0e75e276daaa3a782 Mon Sep 17 00:00:00 2001 From: Daniel O'Connell Date: Tue, 20 Sep 2022 11:28:42 +0100 Subject: [PATCH 1/2] Document the @example annotation for Unit tests --- docs/07-AdvancedUsage.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/docs/07-AdvancedUsage.md b/docs/07-AdvancedUsage.md index 3c8138130..ff25a30a8 100644 --- a/docs/07-AdvancedUsage.md +++ b/docs/07-AdvancedUsage.md @@ -265,6 +265,32 @@ class EndpointCest ``` +## Example Annotation + +As well as the ``\Codeception\Example` attribute, available for Cest tests, the `@example` attribute allows you to +inject test parameters in place of an actual [DataProvider](#dataprovider-attribute) for Unit tests. + +```php +assertNotEmpty($value, "Expected a value"); + } +} +``` +> `@testWith`: as of [Codeception 5.0](https://github.com/Codeception/Codeception/pull/6491), PHPUnit's `@testWith` is no longer supported. `@example` is a good, almost drop-in, replacement. + ## DataProvider Attribute You can also use the `@dataProvider` annotation for creating dynamic examples for [Cest classes](#Cest-Classes), using a **protected method** for providing example data: From 621adab65f9cb64c6951efd23ebaa7092ccaeaa1 Mon Sep 17 00:00:00 2001 From: Daniel O'Connell Date: Tue, 27 Sep 2022 10:08:41 +0100 Subject: [PATCH 2/2] @example update for newer auto-generated docs --- docs/AdvancedUsage.md | 26 ++++++++++++++++++++++++++ guides/07-AdvancedUsage.md | 26 ++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/docs/AdvancedUsage.md b/docs/AdvancedUsage.md index 8b5442d5d..4312780d8 100644 --- a/docs/AdvancedUsage.md +++ b/docs/AdvancedUsage.md @@ -265,6 +265,32 @@ class EndpointCest ``` +## Example Annotation + +As well as the ``\Codeception\Example` attribute, available for Cest tests, the `@example` attribute allows you to +inject test parameters in place of an actual [DataProvider](#dataprovider-attribute) for Unit tests. + +```php +assertNotEmpty($value, "Expected a value"); + } +} +``` +> `@testWith`: as of [Codeception 5.0](https://github.com/Codeception/Codeception/pull/6491), PHPUnit's `@testWith` is no longer supported. `@example` is a good, almost drop-in, replacement. + ## DataProvider Attribute You can also use the `@dataProvider` annotation for creating dynamic examples for [Cest classes](#Cest-Classes), using a **protected method** for providing example data: diff --git a/guides/07-AdvancedUsage.md b/guides/07-AdvancedUsage.md index 473eef8cc..0e0978c61 100644 --- a/guides/07-AdvancedUsage.md +++ b/guides/07-AdvancedUsage.md @@ -258,6 +258,32 @@ class EndpointCest ``` +## Example Annotation + +As well as the ``\Codeception\Example` attribute, available for Cest tests, the `@example` attribute allows you to +inject test parameters in place of an actual [DataProvider](#dataprovider-attribute) for Unit tests. + +```php +assertNotEmpty($value, "Expected a value"); + } +} +``` +> `@testWith`: as of [Codeception 5.0](https://github.com/Codeception/Codeception/pull/6491), PHPUnit's `@testWith` is no longer supported. `@example` is a good, almost drop-in, replacement. + ## DataProvider Attribute You can also use the `@dataProvider` annotation for creating dynamic examples for [Cest classes](#Cest-Classes), using a **protected method** for providing example data: