diff --git a/.gitignore b/.gitignore
index f1f7aef..f114c38 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,6 +4,6 @@ vendor/*
composer.phar
composer.lock
/build/
-/test/codeception/_support/_generated/
+/test/codeception*/_support/_generated/
.phpunit.result.cache
diff --git a/codeception-report.yml b/codeception-report.yml
new file mode 100644
index 0000000..2d2cecf
--- /dev/null
+++ b/codeception-report.yml
@@ -0,0 +1,17 @@
+namespace: Qameta\Allure\Codeception\Test\Report
+
+settings:
+ lint: true
+paths:
+ tests: test/codeception-report
+ output: build
+ support: test/codeception-report/_support
+ data: test/codeception-report/_data
+extensions:
+ enabled:
+ - Qameta\Allure\Codeception\AllureCodeception
+ config:
+ Qameta\Allure\Codeception\AllureCodeception:
+ outputDirectory: allure-results
+ linkTemplates:
+ issue: https://example.org/issues/%s
diff --git a/codeception.yml b/codeception.yml
index 83d7137..59a542a 100644
--- a/codeception.yml
+++ b/codeception.yml
@@ -7,11 +7,3 @@ paths:
output: build
support: test/codeception/_support
data: test/codeception/_data
-extensions:
- enabled:
- - Qameta\Allure\Codeception\AllureCodeception
- config:
- Qameta\Allure\Codeception\AllureCodeception:
- outputDirectory: allure-results
- linkTemplates:
- issue: https://example.org/issues/%s
diff --git a/composer.json b/composer.json
index 5d11539..1cdddfd 100644
--- a/composer.json
+++ b/composer.json
@@ -23,11 +23,10 @@
"require": {
"php": "^8",
"ext-json": "*",
- "codeception/codeception": "^5",
- "allure-framework/allure-php-commons": "^2"
+ "codeception/codeception": "^5.0.3",
+ "allure-framework/allure-php-commons": "^2.3.1"
},
"require-dev": {
- "phpunit/phpunit": "^9.5",
"psalm/plugin-phpunit": "^0.18.4",
"remorhaz/php-json-data": "^0.5.3",
"remorhaz/php-json-path": "^0.7.7",
@@ -41,29 +40,34 @@
},
"autoload-dev": {
"psr-4": {
- "Qameta\\Allure\\Codeception\\Test\\Functional\\": "test/codeception/functional/",
- "Qameta\\Allure\\Codeception\\Test\\Acceptance\\": "test/codeception/acceptance/",
- "Qameta\\Allure\\Codeception\\Test\\Unit\\": "test/codeception/unit/",
- "Qameta\\Allure\\Codeception\\Test\\": [
- "test/codeception/_support/",
- "test/report/"
- ]
+ "Qameta\\Allure\\Codeception\\Test\\": "test/codeception/_support/",
+ "Qameta\\Allure\\Codeception\\Test\\Unit\\": [
+ "test/codeception/report-check/",
+ "test/codeception/unit/"
+ ],
+ "Qameta\\Allure\\Codeception\\Test\\Report\\": "test/codeception-report/_support/",
+ "Qameta\\Allure\\Codeception\\Test\\Report\\Functional\\": "test/codeception-report/functional/",
+ "Qameta\\Allure\\Codeception\\Test\\Report\\Acceptance\\": "test/codeception-report/acceptance/",
+ "Qameta\\Allure\\Codeception\\Test\\Report\\Unit\\": "test/codeception-report/unit/"
}
},
"scripts": {
"build": [
"vendor/bin/codecept build",
- "vendor/bin/codecept gherkin:snippets acceptance"
+ "vendor/bin/codecept build -c codeception-report.yml",
+ "vendor/bin/codecept gherkin:snippets acceptance -c codeception-report.yml"
],
"test-cs": "vendor/bin/phpcs -sp",
+ "test-unit": "vendor/bin/codecept run unit --coverage-text",
"test-report-generate": [
- "rm -rf ./build/log/",
- "vendor/bin/codecept run --no-exit --report"
+ "rm -rf ./build/allure-results/",
+ "vendor/bin/codecept run -c codeception-report.yml --no-exit --report"
],
- "test-report-check": "vendor/bin/phpunit --testsuite=report",
+ "test-report-check": "vendor/bin/codecept run report-check",
"test-psalm": "vendor/bin/psalm --shepherd",
"test": [
"@test-cs",
+ "@test-unit",
"@test-report-generate",
"@test-report-check",
"@test-psalm"
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
deleted file mode 100644
index 8d84520..0000000
--- a/phpunit.xml.dist
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
- test/report/
-
-
-
diff --git a/psalm.xml.dist b/psalm.xml.dist
index 4b5f86f..b305a85 100644
--- a/psalm.xml.dist
+++ b/psalm.xml.dist
@@ -1,14 +1,20 @@
-
+
+
+
+
+
diff --git a/src/AllureCodeception.php b/src/AllureCodeception.php
index 362673e..cbcabc9 100644
--- a/src/AllureCodeception.php
+++ b/src/AllureCodeception.php
@@ -74,7 +74,6 @@ public function moduleInit(): void
$this->testLifecycle = null;
$this->threadDetector = null;
QametaAllure::getLifecycleConfigurator()
- ->setStatusDetector(new StatusDetector(new DefaultStatusDetector()))
->setOutputDirectory($this->getOutputDirectory());
foreach ($this->getLinkTemplates() as $linkType => $linkTemplate) {
QametaAllure::getLifecycleConfigurator()->addLinkTemplate($linkType, $linkTemplate);
@@ -191,7 +190,10 @@ public function testError(FailEvent $failEvent): void
$this
->getTestLifecycle()
->switchToTest($failEvent->getTest())
- ->updateTestFailure($failEvent->getFail());
+ ->updateTestFailure(
+ $failEvent->getFail(),
+ Status::broken(),
+ );
}
/**
@@ -199,10 +201,15 @@ public function testError(FailEvent $failEvent): void
*/
public function testFail(FailEvent $failEvent): void
{
+ $error = $failEvent->getFail();
$this
->getTestLifecycle()
->switchToTest($failEvent->getTest())
- ->updateTestFailure($failEvent->getFail(), Status::failed());
+ ->updateTestFailure(
+ $failEvent->getFail(),
+ Status::failed(),
+ new StatusDetails(message: $error->getMessage(), trace: $error->getTraceAsString()),
+ );
}
/**
@@ -294,6 +301,7 @@ private function getTestLifecycle(): TestLifecycleInterface
Allure::getConfig()->getStatusDetector(),
$this->getThreadDetector(),
Allure::getConfig()->getLinkTemplates(),
+ $_ENV,
);
}
}
diff --git a/src/Internal/TestLifecycle.php b/src/Internal/TestLifecycle.php
index 763b28b..725524a 100644
--- a/src/Internal/TestLifecycle.php
+++ b/src/Internal/TestLifecycle.php
@@ -13,6 +13,7 @@
use Qameta\Allure\AllureLifecycleInterface;
use Qameta\Allure\Codeception\Setup\ThreadDetectorInterface;
use Qameta\Allure\Io\DataSourceFactory;
+use Qameta\Allure\Model\EnvProvider;
use Qameta\Allure\Model\ModelProviderChain;
use Qameta\Allure\Model\Parameter;
use Qameta\Allure\Model\ResultFactoryInterface;
@@ -46,19 +47,13 @@ final class TestLifecycle implements TestLifecycleInterface
*/
private WeakMap $stepStarts;
- /**
- * @param AllureLifecycleInterface $lifecycle
- * @param ResultFactoryInterface $resultFactory
- * @param StatusDetectorInterface $statusDetector
- * @param ThreadDetectorInterface $threadDetector
- * @param LinkTemplateCollectionInterface $linkTemplates
- */
public function __construct(
private AllureLifecycleInterface $lifecycle,
private ResultFactoryInterface $resultFactory,
private StatusDetectorInterface $statusDetector,
private ThreadDetectorInterface $threadDetector,
private LinkTemplateCollectionInterface $linkTemplates,
+ private array $env,
) {
/** @psalm-var WeakMap $this->stepStarts */
$this->stepStarts = new WeakMap();
@@ -143,6 +138,7 @@ public function create(): self
public function updateTest(): self
{
$provider = new ModelProviderChain(
+ new EnvProvider($this->env),
...SuiteProvider::createForChain($this->getCurrentSuite(), $this->linkTemplates),
...TestInfoProvider::createForChain($this->getCurrentTest()),
...$this->createModelProvidersForTest($this->getCurrentTest()->getOriginalTest()),
diff --git a/src/Internal/UnitProvider.php b/src/Internal/UnitProvider.php
index 382bc00..82939a2 100644
--- a/src/Internal/UnitProvider.php
+++ b/src/Internal/UnitProvider.php
@@ -117,6 +117,6 @@ public function getDescriptionHtml(): ?string
public function getFullName(): ?string
{
- return null;
+ return $this->test->getTestCase()::class . '::' . $this->test->getMetadata()->getName();
}
}
diff --git a/src/StatusDetector.php b/src/StatusDetector.php
index 3456596..ed702d6 100644
--- a/src/StatusDetector.php
+++ b/src/StatusDetector.php
@@ -12,6 +12,10 @@
use Qameta\Allure\Setup\StatusDetectorInterface;
use Throwable;
+/**
+ * @deprecated This class is not used anymore and will be removed in next major version.
+ * @psalm-suppress UnusedClass
+ */
final class StatusDetector implements StatusDetectorInterface
{
public function __construct(
diff --git a/test/codeception/_support/AcceptanceTester.php b/test/codeception-report/_support/AcceptanceTester.php
similarity index 90%
rename from test/codeception/_support/AcceptanceTester.php
rename to test/codeception-report/_support/AcceptanceTester.php
index 30da28d..36975a6 100644
--- a/test/codeception/_support/AcceptanceTester.php
+++ b/test/codeception-report/_support/AcceptanceTester.php
@@ -2,11 +2,11 @@
declare(strict_types=1);
-namespace Qameta\Allure\Codeception\Test;
+namespace Qameta\Allure\Codeception\Test\Report;
use Behat\Gherkin\Node\TableNode;
use Codeception\Actor;
-use PHPUnit\Framework\Assert;
+use Codeception\Test\Unit;
use function abs;
use function array_map;
@@ -62,7 +62,7 @@ private function calculate(): void
*/
public function iShouldGetOutputAs($num)
{
- Assert::assertSame([(int) $num], $this->outputs);
+ Unit::assertSame([(int) $num], $this->outputs);
}
/**
@@ -92,7 +92,7 @@ public function iHaveInputs(TableNode $table)
public function iShouldGetNonNegativeOutputs()
{
foreach ($this->outputs as $num) {
- Assert::assertGreaterThanOrEqual(0, $num);
+ Unit::assertGreaterThanOrEqual(0, $num);
}
}
}
diff --git a/test/codeception/_support/FunctionalTester.php b/test/codeception-report/_support/FunctionalTester.php
similarity index 91%
rename from test/codeception/_support/FunctionalTester.php
rename to test/codeception-report/_support/FunctionalTester.php
index c91850c..8c64011 100644
--- a/test/codeception/_support/FunctionalTester.php
+++ b/test/codeception-report/_support/FunctionalTester.php
@@ -2,7 +2,7 @@
declare(strict_types=1);
-namespace Qameta\Allure\Codeception\Test;
+namespace Qameta\Allure\Codeception\Test\Report;
use Codeception\Actor;
diff --git a/test/codeception-report/_support/UnitTester.php b/test/codeception-report/_support/UnitTester.php
new file mode 100644
index 0000000..e984126
--- /dev/null
+++ b/test/codeception-report/_support/UnitTester.php
@@ -0,0 +1,29 @@
+
*/
- public function providerData(): iterable
+ public static function providerData(): iterable
{
return [
0 => ['foo', 'foo'],
diff --git a/test/codeception/unit/StepsTest.php b/test/codeception-report/unit/StepsTest.php
similarity index 86%
rename from test/codeception/unit/StepsTest.php
rename to test/codeception-report/unit/StepsTest.php
index 3553ff4..bbfefb5 100644
--- a/test/codeception/unit/StepsTest.php
+++ b/test/codeception-report/unit/StepsTest.php
@@ -2,15 +2,15 @@
declare(strict_types=1);
-namespace Qameta\Allure\Codeception\Test\Unit;
+namespace Qameta\Allure\Codeception\Test\Report\Unit;
use Codeception\Lib\ModuleContainer;
use Codeception\Scenario;
+use Codeception\Step;
use Codeception\Step\Comment;
use Codeception\Step\Meta;
use Codeception\Test\Unit;
use Exception;
-use PHPUnit\Framework\Assert;
class StepsTest extends Unit
{
@@ -29,11 +29,13 @@ public function testNoStepsError(): void
public function testNoStepsFailure(): void
{
+ /** @psalm-suppress UndefinedClass */
self::fail('Failure');
}
public function testNoStepsSkipped(): void
{
+ /** @psalm-suppress UndefinedClass */
self::markTestSkipped('Skipped');
}
@@ -78,12 +80,12 @@ public function testTwoStepsSecondFails(): void
$scenario->runStep($this->createFailingStep('Step 2 name', 'Failure'));
}
- private function createFailingStep(string $name, string $failure): \Codeception\Step
+ private function createFailingStep(string $name, string $failure): Step
{
return new class ($failure, $name) extends Meta {
- private $failure;
+ private string $failure;
- public function __construct(string $failure, $action, array $arguments = [])
+ public function __construct(string $failure, string $action, array $arguments = [])
{
parent::__construct($action, $arguments);
$this->failure = $failure;
@@ -92,7 +94,7 @@ public function __construct(string $failure, $action, array $arguments = [])
public function run(ModuleContainer $container = null): void
{
$this->setFailed(true);
- Assert::fail($this->failure);
+ Unit::fail($this->failure);
}
};
}
diff --git a/test/codeception/report-check.suite.yml b/test/codeception/report-check.suite.yml
new file mode 100644
index 0000000..a81cedd
--- /dev/null
+++ b/test/codeception/report-check.suite.yml
@@ -0,0 +1,2 @@
+
+actor: UnitTester
diff --git a/test/report/ReportTest.php b/test/codeception/report-check/ReportTest.php
similarity index 94%
rename from test/report/ReportTest.php
rename to test/codeception/report-check/ReportTest.php
index 8be2570..09f74f5 100644
--- a/test/report/ReportTest.php
+++ b/test/codeception/report-check/ReportTest.php
@@ -2,12 +2,12 @@
declare(strict_types=1);
-namespace Qameta\Allure\Codeception\Test;
+namespace Qameta\Allure\Codeception\Test\Unit;
-use PHPUnit\Framework\TestCase;
-use Qameta\Allure\Codeception\Test\Functional\NestedStepsCest;
-use Qameta\Allure\Codeception\Test\Unit\AnnotationTest;
-use Qameta\Allure\Codeception\Test\Unit\StepsTest;
+use Codeception\Test\Unit;
+use Qameta\Allure\Codeception\Test\Report\Functional\NestedStepsCest;
+use Qameta\Allure\Codeception\Test\Report\Unit\AnnotationTest;
+use Qameta\Allure\Codeception\Test\Report\Unit\StepsTest;
use Remorhaz\JSON\Data\Value\EncodedJson\NodeValueFactory;
use Remorhaz\JSON\Data\Value\NodeValueInterface;
use Remorhaz\JSON\Path\Processor\Processor;
@@ -25,7 +25,7 @@
use const DIRECTORY_SEPARATOR;
use const PATHINFO_EXTENSION;
-class ReportTest extends TestCase
+class ReportTest extends Unit
{
/**
* @var array>
@@ -38,7 +38,7 @@ class ReportTest extends TestCase
public static function setUpBeforeClass(): void
{
- $buildPath = __DIR__ . '/../../build/allure-results';
+ $buildPath = __DIR__ . '/../../../build/allure-results';
$files = scandir($buildPath);
$jsonValueFactory = NodeValueFactory::create();
@@ -84,7 +84,7 @@ public static function setUpBeforeClass(): void
* @param string $class
* @param string $method
* @param string $jsonPath
- * @param string $expectedValue
+ * @param non-empty-string $expectedValue
* @dataProvider providerSingleNodeValueStartsFromString
*/
public function testSingleNodeValueStartsFromString(
@@ -110,9 +110,9 @@ public function testSingleNodeValueStartsFromString(
}
/**
- * @return iterable
+ * @return iterable
*/
- public function providerSingleNodeValueStartsFromString(): iterable
+ public static function providerSingleNodeValueStartsFromString(): iterable
{
return [
'Error message in test case without steps' => [
@@ -147,7 +147,7 @@ public function testExistingNodeValue(
/**
* @return iterable}>
*/
- public function providerExistingNodeValue(): iterable
+ public static function providerExistingNodeValue(): iterable
{
return [
'Test case title annotation' => [
@@ -172,13 +172,13 @@ public function providerExistingNodeValue(): iterable
AnnotationTest::class,
'testStoriesAnnotation',
'$.labels[?(@.name=="story")].value',
- ['Story 1', 'Story 2'],
+ ['Story 2', 'Story 1'],
],
'Test case features annotation' => [
AnnotationTest::class,
'testFeaturesAnnotation',
'$.labels[?(@.name=="feature")].value',
- ['Feature 1', 'Feature 2'],
+ ['Feature 2', 'Feature 1'],
],
'Successful test case without steps' => [
StepsTest::class,
diff --git a/test/codeception/unit.suite.yml b/test/codeception/unit.suite.yml
index a81cedd..bfaf844 100644
--- a/test/codeception/unit.suite.yml
+++ b/test/codeception/unit.suite.yml
@@ -1,2 +1,6 @@
actor: UnitTester
+coverage:
+ enabled: true
+ include:
+ - src/*
\ No newline at end of file
diff --git a/test/codeception/unit/Internal/ArgumentAsStringTest.php b/test/codeception/unit/Internal/ArgumentAsStringTest.php
new file mode 100644
index 0000000..a77cb87
--- /dev/null
+++ b/test/codeception/unit/Internal/ArgumentAsStringTest.php
@@ -0,0 +1,32 @@
+
+ */
+ public static function providerString(): iterable
+ {
+ return [
+ 'Simple string' => ['a', '"a"'],
+ 'String with tabulation' => ["a\tb", '"a b"'],
+ 'String with line feed' => ["a\nb", '"a\\\\nb"'],
+ 'String with carriage return' => ["a\rb", '"a\\\\rb"'],
+ ];
+ }
+}
diff --git a/test/codeception/unit/CestProviderTest.php b/test/codeception/unit/Internal/CestProviderTest.php
similarity index 72%
rename from test/codeception/unit/CestProviderTest.php
rename to test/codeception/unit/Internal/CestProviderTest.php
index 1c6cc7b..42913c1 100644
--- a/test/codeception/unit/CestProviderTest.php
+++ b/test/codeception/unit/Internal/CestProviderTest.php
@@ -2,7 +2,7 @@
declare(strict_types=1);
-namespace Qameta\Allure\Codeception\Test\Unit;
+namespace Qameta\Allure\Codeception\Test\Unit\Internal;
use Codeception\Test\Cest;
use Codeception\Test\Unit;
@@ -17,4 +17,11 @@ public function testFullName(): void
$this->assertSame(__CLASS__ . '::' . 'a', $cestProvider->getFullName());
}
+
+ /**
+ * @psalm-suppress PossiblyUnusedMethod
+ */
+ public function a(): void
+ {
+ }
}