Skip to content

Commit 88bccf5

Browse files
authored
fix status detection (via allure-framework#64)
1 parent ffad875 commit 88bccf5

14 files changed

+68
-40
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
},
3131
"require": {
3232
"php": "^8",
33-
"allure-framework/allure-php-commons": "^2.0.0-rc1",
33+
"allure-framework/allure-php-commons": "2.0.0-rc3",
3434
"phpunit/phpunit": "^9"
3535
},
3636
"require-dev": {

src/AllureExtension.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,15 @@ public function executeAfterTestFailure(string $test, string $message, float $ti
100100
$this
101101
->testLifecycle
102102
->switchTo($test)
103-
->updateDetectedStatus($message, Status::failed());
103+
->updateDetectedStatus($message, Status::failed(), Status::failed());
104104
}
105105

106106
public function executeAfterTestError(string $test, string $message, float $time): void
107107
{
108108
$this
109109
->testLifecycle
110110
->switchTo($test)
111-
->updateDetectedStatus($message, Status::failed());
111+
->updateDetectedStatus($message, Status::broken());
112112
}
113113

114114
public function executeAfterIncompleteTest(string $test, string $message, float $time): void

src/Internal/TestLifecycle.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,11 @@ public function updateStatus(?string $message = null, ?Status $status = null): s
115115
return $this;
116116
}
117117

118-
public function updateDetectedStatus(?string $message = null, ?Status $status = null): self
119-
{
118+
public function updateDetectedStatus(
119+
?string $message = null,
120+
?Status $status = null,
121+
?Status $overrideStatus = null,
122+
): self {
120123
$exception = $this->adapter->getLastException();
121124
if (!isset($exception)) {
122125
return $this->updateStatus($message, $status);
@@ -127,6 +130,7 @@ public function updateDetectedStatus(?string $message = null, ?Status $status =
127130
$testResult,
128131
$this->statusDetector,
129132
$exception,
133+
$overrideStatus,
130134
),
131135
$this->adapter->getTestId($this->getCurrentTest()),
132136
);

src/Internal/TestLifecycleInterface.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@ public function write(): TestLifecycleInterface;
2323

2424
public function updateStatus(?string $message = null, ?Status $status = null): TestLifecycleInterface;
2525

26-
public function updateDetectedStatus(?string $message = null, ?Status $status = null): TestLifecycleInterface;
26+
public function updateDetectedStatus(
27+
?string $message = null,
28+
?Status $status = null,
29+
?Status $overrideStatus = null,
30+
): TestLifecycleInterface;
2731

2832
public function switchTo(string $test): TestLifecycleInterface;
2933

src/Internal/TestUpdater.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function setInfo(TestResult $testResult, TestInfo $info): void
3030
$parser = $this->parseAnnotations($info);
3131

3232
$testResult
33-
->setName($parser->getTitle() ?? $info->getName())
33+
->setName($parser->getDisplayName() ?? $info->getName())
3434
->setFullName($info->getFullName())
3535
->setDescriptionHtml($parser->getDescriptionHtml())
3636
->setDescription($parser->getDescription())
@@ -122,10 +122,14 @@ public function setRunInfo(TestResult $testResult, TestRunInfo $runInfo): void
122122
->setRerunOf($runInfo->getRerunOf());
123123
}
124124

125-
public function setDetectedStatus(TestResult $test, StatusDetectorInterface $statusDetector, Throwable $e): void
126-
{
125+
public function setDetectedStatus(
126+
TestResult $test,
127+
StatusDetectorInterface $statusDetector,
128+
Throwable $e,
129+
?Status $overrideStatus = null,
130+
): void {
127131
$test
128-
->setStatus($statusDetector->getStatus($e))
132+
->setStatus($overrideStatus ?? $statusDetector->getStatus($e))
129133
->setStatusDetails($statusDetector->getStatusDetails($e));
130134
}
131135

src/Internal/TestUpdaterInterface.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,12 @@ public function setInfo(TestResult $testResult, TestInfo $info): void;
1919

2020
public function setRunInfo(TestResult $testResult, TestRunInfo $runInfo): void;
2121

22-
public function setDetectedStatus(TestResult $test, StatusDetectorInterface $statusDetector, Throwable $e): void;
22+
public function setDetectedStatus(
23+
TestResult $test,
24+
StatusDetectorInterface $statusDetector,
25+
Throwable $e,
26+
?Status $overrideStatus = null,
27+
): void;
2328

2429
public function setStatus(TestResult $test, ?string $message = null, ?Status $status = null): void;
2530
}

test/report/Generate/Annotation/TitleClassLevelMixedTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* @Title ("This test has wrong title")
1313
*/
1414
#[
15-
Attribute\Title('Native class-level annotation overrides legacy one if both are used'),
15+
Attribute\DisplayName('Native class-level annotation overrides legacy one if both are used'),
1616
Attribute\Epic('Annotations'),
1717
Attribute\Feature('Title'),
1818
]

test/report/Generate/Annotation/TitleClassLevelNativeTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
use Qameta\Allure\Attribute;
99

1010
#[
11-
Attribute\Title('Test without title annotation uses class-level native title annotation'),
11+
Attribute\DisplayName('Test without title annotation uses class-level native title annotation'),
1212
Attribute\Epic('Annotations'),
1313
Attribute\Feature('Title'),
1414
]

test/report/Generate/Annotation/TitleTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function testLegacyTitleAnnotation(): void
3131
$this->expectNotToPerformAssertions();
3232
}
3333

34-
#[Attribute\Title('Native title annotation is reported as test title')]
34+
#[Attribute\DisplayName('Native display name annotation is reported as test title')]
3535
public function testNativeTitleAnnotation(): void
3636
{
3737
$this->expectNotToPerformAssertions();
@@ -40,7 +40,7 @@ public function testNativeTitleAnnotation(): void
4040
/**
4141
* @Title ("This is wrong title for this test")
4242
*/
43-
#[Attribute\Title('Native title annotation overrides legacy one')]
43+
#[Attribute\DisplayName('Native display name annotation overrides legacy one')]
4444
public function testMixedTitleAnnotation(): void
4545
{
4646
$this->expectNotToPerformAssertions();

test/report/Generate/AnnotationTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ class AnnotationTest extends TestCase
2222
/**
2323
* @Description ("Legacy description with `markdown`", type = DescriptionType::MARKDOWN)
2424
*/
25-
#[Attribute\Title('Legacy description annotation is reported as test description')]
25+
#[Attribute\DisplayName('Legacy description annotation is reported as test description')]
2626
public function testLegacyDescriptionAnnotation(): void
2727
{
2828
$this->expectNotToPerformAssertions();
2929
}
3030

3131
#[
32-
Attribute\Title('Native description annotation is reported as test description'),
32+
Attribute\DisplayName('Native description annotation is reported as test description'),
3333
Attribute\Description('Test native description with `markdown`'),
3434
]
3535
public function testNativeDescriptionAnnotation(): void
@@ -49,14 +49,14 @@ public function testMixedDescriptionAnnotation(): void
4949
/**
5050
* @Severity (level = SeverityLevel::MINOR)
5151
*/
52-
#[Attribute\Title('Legacy severity annotation is reported as test severity')]
52+
#[Attribute\DisplayName('Legacy severity annotation is reported as test severity')]
5353
public function testLegacySeverityAnnotation(): void
5454
{
5555
$this->expectNotToPerformAssertions();
5656
}
5757

5858
#[
59-
Attribute\Title('Native severity annotation is reported as test severity'),
59+
Attribute\DisplayName('Native severity annotation is reported as test severity'),
6060
Attribute\Severity(Attribute\Severity::CRITICAL),
6161
]
6262
public function testNativeSeverityAnnotation(): void
@@ -68,7 +68,7 @@ public function testNativeSeverityAnnotation(): void
6868
* @Severity (level = SeverityLevel::MINOR)
6969
*/
7070
#[
71-
Attribute\Title('Legacy severity annotation overrides native one'),
71+
Attribute\DisplayName('Legacy severity annotation overrides native one'),
7272
Attribute\Severity(Attribute\Severity::CRITICAL),
7373
]
7474
public function testMixedSeverityAnnotation(): void
@@ -79,7 +79,7 @@ public function testMixedSeverityAnnotation(): void
7979
/**
8080
* @Parameter (name = "foo", value = "legacy foo")
8181
*/
82-
#[Attribute\Title('Legacy parameter')]
82+
#[Attribute\DisplayName('Legacy parameter')]
8383
public function testLegacyParameterAnnotation(): void
8484
{
8585
$this->expectNotToPerformAssertions();

0 commit comments

Comments
 (0)