Skip to content

Commit 6e13d27

Browse files
authored
add acceptance tests (via #66)
1 parent ac3d471 commit 6e13d27

File tree

9 files changed

+545
-6
lines changed

9 files changed

+545
-6
lines changed

.github/workflows/build.yml

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,33 @@ on:
99
- 'master'
1010

1111
jobs:
12-
build:
12+
build71:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v1
16+
- uses: shivammathur/setup-php@v2
17+
with:
18+
php-version: '7.1.3'
19+
- name: Install
20+
run: composer install
21+
- name: Install
22+
run: composer validate
23+
- name: Test
24+
run: composer test
25+
build72:
26+
runs-on: ubuntu-latest
27+
steps:
28+
- uses: actions/checkout@v1
29+
- uses: shivammathur/setup-php@v2
30+
with:
31+
php-version: '7.2'
32+
- name: Install
33+
run: composer install
34+
- name: Install
35+
run: composer validate
36+
- name: Test
37+
run: composer test
38+
build73:
1339
runs-on: ubuntu-latest
1440
steps:
1541
- uses: actions/checkout@v1
@@ -20,3 +46,31 @@ jobs:
2046
run: composer install
2147
- name: Install
2248
run: composer validate
49+
- name: Test
50+
run: composer test
51+
build74:
52+
runs-on: ubuntu-latest
53+
steps:
54+
- uses: actions/checkout@v1
55+
- uses: shivammathur/setup-php@v2
56+
with:
57+
php-version: '7.4'
58+
- name: Install
59+
run: composer install
60+
- name: Install
61+
run: composer validate
62+
- name: Test
63+
run: composer test
64+
build80:
65+
runs-on: ubuntu-latest
66+
steps:
67+
- uses: actions/checkout@v1
68+
- uses: shivammathur/setup-php@v2
69+
with:
70+
php-version: '8.0'
71+
- name: Install
72+
run: composer install
73+
- name: Install
74+
run: composer validate
75+
- name: Test
76+
run: composer test

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@
33
vendor/*
44
composer.phar
55
composer.lock
6+
/build/
7+
.phpunit.result.cache
8+

codeception.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
namespace: Yandex\Allure\Codeception
2+
suites:
3+
unit:
4+
path: .
5+
6+
settings:
7+
lint: true
8+
paths:
9+
tests: test/codeception
10+
output: build
11+
support: test/codeception/_support
12+
data: test/codeception
13+
extensions:
14+
enabled:
15+
- Yandex\Allure\Codeception\AllureCodeception
16+
config:
17+
Yandex\Allure\Codeception\AllureCodeception:
18+
deletePreviousResults: true
19+
outputDirectory: allure-results
20+
21+

composer.json

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,37 @@
1616
"source": "https://github.com/allure-framework/allure-codeception"
1717
},
1818
"require": {
19-
"php": ">=5.6",
20-
"codeception/codeception": "^2.3|^3.0|^4.0",
21-
"allure-framework/allure-php-api": "~1.2.1",
22-
"symfony/filesystem": ">=2.6",
23-
"symfony/finder": ">=2.6"
19+
"php": ">=7.1.3",
20+
"ext-json": "*",
21+
"codeception/codeception": "^2.5 | ^3 | ^4",
22+
"allure-framework/allure-php-api": "^1.3",
23+
"symfony/filesystem": "^2.7 | ^3 | ^4 | ^5",
24+
"symfony/finder": "^2.7 | ^3 | ^4 | ^5"
25+
},
26+
"require-dev": {
27+
"ext-dom": "*",
28+
"phpunit/phpunit": "^7.2 | ^8 | ^9"
2429
},
2530
"autoload": {
2631
"psr-0": {
2732
"Yandex": "src/"
2833
}
34+
},
35+
"autoload-dev": {
36+
"psr-4": {
37+
"Yandex\\Allure\\Codeception\\": [
38+
"test/report/",
39+
"test/unit/"
40+
]
41+
}
42+
},
43+
"scripts": {
44+
"test-report": [
45+
"vendor/bin/codecept run --no-exit --report",
46+
"vendor/bin/phpunit --testsuite=report"
47+
],
48+
"test": [
49+
"@test-report"
50+
]
2951
}
3052
}

phpunit.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/7.2/phpunit.xsd"
5+
colors="true"
6+
defaultTestSuite="unit">
7+
<testsuites>
8+
<testsuite name="report">
9+
<directory>test/report/</directory>
10+
</testsuite>
11+
</testsuites>
12+
</phpunit>
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Yandex\Allure\Codeception;
6+
7+
use Codeception\Test\Unit;
8+
use Yandex\Allure\Adapter\Annotation\Description;
9+
use Yandex\Allure\Adapter\Annotation\Features;
10+
use Yandex\Allure\Adapter\Annotation\Parameter;
11+
use Yandex\Allure\Adapter\Annotation\Severity;
12+
use Yandex\Allure\Adapter\Annotation\Stories;
13+
use Yandex\Allure\Adapter\Annotation\Title;
14+
use Yandex\Allure\Adapter\Model\DescriptionType;
15+
use Yandex\Allure\Adapter\Model\ParameterKind;
16+
use Yandex\Allure\Adapter\Model\SeverityLevel;
17+
18+
class AnnotationTest extends Unit
19+
{
20+
21+
/**
22+
* @Title ("Test title")
23+
*/
24+
public function testTitleAnnotation(): void
25+
{
26+
$this->expectNotToPerformAssertions();
27+
}
28+
29+
/**
30+
* @Description ("Test description with `markdown`", type = DescriptionType::MARKDOWN)
31+
*/
32+
public function testDescriptionAnnotation(): void
33+
{
34+
$this->expectNotToPerformAssertions();
35+
}
36+
37+
/**
38+
* @Severity (level = SeverityLevel::MINOR)
39+
*/
40+
public function testSeverityAnnotation(): void
41+
{
42+
$this->expectNotToPerformAssertions();
43+
}
44+
45+
/**
46+
* @Parameter (name = "foo", value = "bar", kind = ParameterKind::ARGUMENT)
47+
*/
48+
public function testParameterAnnotation(): void
49+
{
50+
$this->expectNotToPerformAssertions();
51+
}
52+
53+
/**
54+
* @Stories ("Story 1", "Story 2")
55+
*/
56+
public function testStoriesAnnotation(): void
57+
{
58+
$this->expectNotToPerformAssertions();
59+
}
60+
61+
/**
62+
* @Features ("Feature 1", "Feature 2")
63+
*/
64+
public function testFeaturesAnnotation(): void
65+
{
66+
$this->expectNotToPerformAssertions();
67+
}
68+
}

test/codeception/StepsTest.php

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Yandex\Allure\Codeception;
6+
7+
use Codeception\Lib\ModuleContainer;
8+
use Codeception\Scenario;
9+
use Codeception\Step\Assertion;
10+
use Codeception\Step\Comment;
11+
use Codeception\Step\Meta;
12+
use Codeception\Step\TryTo;
13+
use Codeception\Test\Unit;
14+
use Exception;
15+
use PHPUnit\Framework\Assert;
16+
17+
class StepsTest extends Unit
18+
{
19+
20+
public function testNoStepsSuccess(): void
21+
{
22+
$this->expectNotToPerformAssertions();
23+
}
24+
25+
/**
26+
* @throws Exception
27+
*/
28+
public function testNoStepsError(): void
29+
{
30+
throw new Exception('Error');
31+
}
32+
33+
public function testNoStepsFailure(): void
34+
{
35+
self::fail('Failure');
36+
}
37+
38+
public function testNoStepsSkipped(): void
39+
{
40+
self::markTestSkipped('Skipped');
41+
}
42+
43+
public function testSingleSuccessfulStepWithTitle(): void
44+
{
45+
$this->expectNotToPerformAssertions();
46+
$scenario = new Scenario($this);
47+
$scenario->runStep(new Comment('Step 1 name'));
48+
}
49+
50+
public function testTwoSuccessfulSteps(): void
51+
{
52+
$this->expectNotToPerformAssertions();
53+
54+
$scenario = new Scenario($this);
55+
$scenario->runStep(new Comment('Step 1 name'));
56+
$scenario->runStep(new Comment('Step 2 name'));
57+
}
58+
59+
public function testTwoStepsFirstFails(): void
60+
{
61+
$this->expectNotToPerformAssertions();
62+
63+
$scenario = new Scenario($this);
64+
$scenario->runStep($this->createFailingStep('Step 1 name', 'Failure'));
65+
$scenario->runStep(new Comment('Step 2 name'));
66+
}
67+
68+
public function testTwoStepsSecondFails(): void
69+
{
70+
$this->expectNotToPerformAssertions();
71+
72+
$scenario = new Scenario($this);
73+
$scenario->runStep(new Comment('Step 1 name'));
74+
$scenario->runStep($this->createFailingStep('Step 2 name', 'Failure'));
75+
}
76+
77+
private function createFailingStep(string $name, string $failure): \Codeception\Step
78+
{
79+
return new class ($failure, $name) extends Meta {
80+
81+
private $failure;
82+
83+
public function __construct(string $failure, $action, array $arguments = [])
84+
{
85+
parent::__construct($action, $arguments);
86+
$this->failure = $failure;
87+
}
88+
89+
public function run(ModuleContainer $container = null)
90+
{
91+
$this->setFailed(true);
92+
Assert::fail($this->failure);
93+
}
94+
};
95+
}
96+
}

test/codeception/_support/.gitkeep

Whitespace-only changes.

0 commit comments

Comments
 (0)