Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
],
"require": {
"php": "^8.0",
"qase/php-commons": "^2.1.12",
"qase/php-commons": "^2.1.18",
"codeception/codeception": "^5.2"
},
"require-dev": {
Expand All @@ -35,7 +35,7 @@
"Tests\\": "tests/"
}
},
"version": "2.1.4",
"version": "2.1.5",
"config": {
"optimize-autoloader": true,
"preferred-install": {
Expand Down
65 changes: 33 additions & 32 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 40 additions & 0 deletions docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,44 @@ public function testLogin(): void
}
```

#### Tags
Adds tags to the test case. Can be used on classes and methods. Tags from both levels are merged.

```php
use Qase\Codeception\Attributes\Tags;

// Single attribute with multiple tags
#[Tags('smoke', 'regression')]
public function testLogin(): void
{
$this->assertTrue(true);
}

// Multiple Tags attributes
#[Tags('smoke')]
#[Tags('regression')]
public function testLogin(): void
{
$this->assertTrue(true);
}

// Class-level + method-level merge
#[Tags('smoke')]
class AuthTest extends \Codeception\Test\Unit
{
#[Tags('regression')]
public function testLogin(): void
{
// Gets both 'smoke' and 'regression' tags
}

public function testLogout(): void
{
// Gets only 'smoke' tag (inherited from class)
}
}
```

#### Parameter
Adds parameters to the test case. Useful for parameterized tests.

Expand All @@ -101,6 +139,7 @@ use Qase\Codeception\Attributes\QaseId;
use Qase\Codeception\Attributes\Title;
use Qase\Codeception\Attributes\Suite;
use Qase\Codeception\Attributes\Field;
use Qase\Codeception\Attributes\Tags;
use Qase\Codeception\Attributes\Parameter;
use Tests\Support\UnitTester;

Expand All @@ -114,6 +153,7 @@ class LoginTest extends \Codeception\Test\Unit
#[Suite('Critical Features')]
#[Field('description', 'Test verifies successful user login')]
#[Field('severity', 'high')]
#[Tags('smoke')]
#[Parameter('user_type', 'admin')]
public function testSuccessfulLogin(): void
{
Expand Down
3 changes: 3 additions & 0 deletions examples/tests/Unit/AttributeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@
use Qase\Codeception\Attributes\QaseId;
use Qase\Codeception\Attributes\QaseIds;
use Qase\Codeception\Attributes\Suite;
use Qase\Codeception\Attributes\Tags;
use Qase\Codeception\Attributes\Title;
use Tests\Support\UnitTester;

#[Tags("smoke")]
class AttributeTest extends \Codeception\Test\Unit
{
protected UnitTester $tester;
Expand Down Expand Up @@ -64,6 +66,7 @@ public function testWithSuites(): void
#[Field('severity', 'critical')]
#[Field('priority', 'high')]
#[Field('layer', 'unit')]
#[Tags('regression')]
public function testWithFields(): void
{
$this->assertCount(3, [1, 2, 3]);
Expand Down
2 changes: 2 additions & 0 deletions examples/tests/Unit/CombinedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Qase\Codeception\Attributes\Parameter;
use Qase\Codeception\Attributes\QaseId;
use Qase\Codeception\Attributes\Suite;
use Qase\Codeception\Attributes\Tags;
use Qase\Codeception\Attributes\Title;
use Tests\Support\UnitTester;

Expand All @@ -21,6 +22,7 @@ class CombinedTest extends \Codeception\Test\Unit
#[Suite('Combined')]
#[Field('severity', 'critical')]
#[Field('priority', 'high')]
#[Tags('smoke')]
#[Parameter('user', 'admin')]
#[Parameter('role', 'superuser')]
public function testFullMetadata(): void
Expand Down
9 changes: 9 additions & 0 deletions expected/codeception-examples.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ results:
fields:
severity: critical
priority: high
tags: smoke
params:
user: admin
role: superuser
Expand Down Expand Up @@ -51,6 +52,7 @@ results:
testops_ids:
- 4
status: skipped
tags: smoke
relations:
suite:
data:
Expand All @@ -67,6 +69,7 @@ results:
testops_ids:
- 1
status: passed
tags: smoke
relations:
suite:
data:
Expand All @@ -83,6 +86,7 @@ results:
testops_ids:
- 8
status: passed
tags: smoke
relations:
suite:
data:
Expand All @@ -95,6 +99,7 @@ results:
testops_ids:
- 5
status: passed
tags: smoke
relations:
suite:
data:
Expand All @@ -111,6 +116,7 @@ results:
testops_ids:
- 3
status: invalid
tags: smoke
relations:
suite:
data:
Expand Down Expand Up @@ -150,6 +156,7 @@ results:
severity: critical
priority: high
layer: unit
tags: smoke,regression
relations:
suite:
data:
Expand All @@ -166,6 +173,7 @@ results:
testops_ids:
- 2
status: failed
tags: smoke
relations:
suite:
data:
Expand All @@ -183,6 +191,7 @@ results:
- 6
- 7
status: passed
tags: smoke
relations:
suite:
data:
Expand Down
4 changes: 4 additions & 0 deletions src/Attributes/AttributeParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ private function getMetadataFromAnnotations(array $annotations): Metadata
if ($annotation instanceof ParameterAttributeInterface) {
$metadata->parameters[$annotation->getName()] = $annotation->getValue();
}

if ($annotation instanceof TagsAttributeInterface) {
$metadata->tags = array_merge($metadata->tags, $annotation->getTags());
}
}

return $metadata;
Expand Down
Loading
Loading