-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathNegativeTest.php
More file actions
81 lines (67 loc) · 2.18 KB
/
Copy pathNegativeTest.php
File metadata and controls
81 lines (67 loc) · 2.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?php
declare(strict_types=1);
namespace Qameta\Allure\PHPUnit\Test\Report\Generate;
use PHPUnit\Framework\Attributes\DoesNotPerformAssertions;
use PHPUnit\Framework\TestCase;
use Qameta\Allure\Allure;
use Qameta\Allure\Attribute\DisplayName;
use Qameta\Allure\PHPUnit\ExceptionDetailsTrait;
use RuntimeException;
use function trigger_error;
use const E_USER_WARNING;
final class NegativeTest extends TestCase
{
use ExceptionDetailsTrait;
#[DisplayName('Test with failed assertion is reported as failed')]
public function testFailedWithoutSteps(): void
{
self::fail("Failure message");
}
#[DisplayName('Test with failed assertion in step is reported as failed')]
public function testFailedWithSteps(): void
{
Allure::addStep('Successful step');
Allure::runStep(
#[DisplayName('Failed step')]
function () {
self::fail('Failure message');
}
);
}
#[DisplayName('Test that throws exception is reported as failed')]
public function testException(): void
{
throw new RuntimeException('Exception message');
}
#[DisplayName('Test that throws exception in step is reported as failed')]
public function testExceptionWithSteps(): void
{
Allure::addStep('Successful step');
Allure::runStep(
#[DisplayName('Failed step')]
function () {
throw new RuntimeException('Exception message');
}
);
}
#[DisplayName('Test that emits warning is reported as broken'), DoesNotPerformAssertions]
public function testWarning(): void
{
trigger_error('"Test triggered warning"', E_USER_WARNING);
}
#[DisplayName('Skipped test is reported as skipped')]
public function testSkipped(): void
{
self::markTestSkipped('Skipped message');
}
#[DisplayName('Incomplete test is reported as broken')]
public function testIncomplete(): void
{
self::markTestIncomplete('Incomplete message');
}
#[DisplayName('Risky test is reported as failed')]
public function testRisky(): void
{
// Not performing assertions makes test risky
}
}