Skip to content

Commit 3884842

Browse files
authored
prepare for release (via allure-framework#69)
1 parent 31995bd commit 3884842

34 files changed

+28
-126
lines changed

README.md

Lines changed: 21 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -49,53 +49,36 @@ Then add Allure test listener in **phpunit.xml** file:
4949
<extension class="Qameta\Allure\PHPUnit\AllureExtension">
5050
<!-- Optional arguments block; omit it if you want to use default values -->
5151
<arguments>
52-
<!-- JSON files output directory (default is build/allure-results; you may pass null to use default value) -->
53-
<string>build/allure-results</string>
54-
<!-- Configurator object class (default is Qameta\Allure\PHPUnit\Setup\DefaultConfigurator; you pass null to use default value) -->
55-
<string>Qameta\Allure\PHPUnit\Setup\DefaultConfigurator</string>
56-
<!-- Other arguments (if any) are passed to configurator's constructor -->
52+
<!-- Path to config file (default is config/allure.config.php) -->
53+
<string>config/allure.config.php</string>
5754
</arguments>
5855
</extension>
5956
</extensions>
6057
```
61-
After running PHPUnit tests a new folder will be created (**build/allure-results** in the example above). This folder will contain generated JSON files. See [framework help](https://docs.qameta.io/allure/#_reporting) for details about how to generate report from JSON files. By default generated report will only show a limited set of information but you can use cool Allure features by adding a minimum of test code changes. Read next section for details.
62-
63-
You can also use setup hook to tune or extend Allure lifecycle:
64-
```xml
65-
<extensions>
66-
<extension class="Qameta\Allure\PHPUnit\AllureExtension">
67-
<!-- Optional arguments block; omit it if you want to use default values -->
68-
<arguments>
69-
<!-- JSON files output directory (default is build/allure-results; you may pass null to use default value) -->
70-
<null/>
71-
<!-- Configurator object class (default is Qameta\Allure\PHPUnit\Setup\DefaultConfigurator; you pass null to use default value) -->
72-
<null/>
73-
<!-- For default configurator, just pass name of invokable class in this argument -->
74-
<string>My\Namespace\OnSetupHook</string>
75-
</arguments>
76-
</extension>
77-
</extensions>
78-
```
79-
80-
And the hook class could look like this:
81-
58+
Config is common PHP file that should return an array:
8259
```php
8360
<?php
8461

85-
namespace My\Namespace;
86-
87-
use Qameta\Allure\Allure;
88-
89-
class OnSetupHook
90-
{
91-
public function __invoke(): void
92-
{
93-
Allure::getLifecycleConfigurator()->addHooks(new MyHook())
94-
}
95-
}
62+
return [
63+
// Path to output directory (default is build/allure-results)
64+
'outputDirectory' => 'build/allure-results',
65+
'linkTemplates' => [
66+
// Class or object must implement \Qameta\Allure\Setup\LinkTemplateInterface
67+
'tms' => \My\LinkTemplate::class,
68+
],
69+
'setupHook' => function (): void {
70+
// Some actions performed before starting the lifecycle
71+
},
72+
// Class or object must implement \Qameta\Allure\PHPUnit\Setup\ThreadDetectorInterface
73+
'threadDetector' => \My\ThreadDetector::class,
74+
'lifecycleHooks' => [
75+
// Class or object must implement one of \Qameta\Allure\Hook\LifecycleHookInterface descendants.
76+
\My\LifecycleHook::class,
77+
],
78+
];
9679
```
9780

98-
In the above example we add some custom hook `MyHook` to Allure lifecycle.
81+
After running PHPUnit tests a new folder will be created (**build/allure-results** in the example above). This folder will contain generated JSON files. See [framework help](https://docs.qameta.io/allure/#_reporting) for details about how to generate report from JSON files. By default generated report will only show a limited set of information but you can use cool Allure features by adding a minimum of test code changes. Read next section for details.
9982

10083
## Main features
10184
This adapter comes with a set of PHP annotations and traits allowing to use main Allure features.

composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@
3030
},
3131
"require": {
3232
"php": "^8",
33-
"allure-framework/allure-php-commons": "2.0.0-rc4",
33+
"allure-framework/allure-php-commons": "^2",
3434
"phpunit/phpunit": "^9"
3535
},
3636
"require-dev": {
37-
"brianium/paratest": "^6.3.3",
37+
"brianium/paratest": "^6.4.1",
3838
"psalm/plugin-phpunit": "^0.16.1",
39-
"squizlabs/php_codesniffer": "^3.6.1",
40-
"vimeo/psalm": "^4.13.1"
39+
"squizlabs/php_codesniffer": "^3.6.2",
40+
"vimeo/psalm": "^4.16.1"
4141
},
4242
"conflict": {
4343
"amphp/byte-stream": "<1.5.1"

src/AllureAdapter.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
final class AllureAdapter implements AllureAdapterInterface
1717
{
18-
1918
private static ?AllureAdapterInterface $instance = null;
2019

2120
/**

src/AllureAdapterInterface.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
interface AllureAdapterInterface
1414
{
15-
1615
public function registerStart(ContainerResult $containerResult, TestResult $testResult, TestInfo $info): string;
1716

1817
public function registerRun(TestResult $testResult, TestInfo $info): TestRunInfo;

src/AllureExtension.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,9 @@ private function createTestLifecycle(string|array|ConfigInterface|null $configSo
7474

7575
private function setupAllure(ConfigInterface $config): void
7676
{
77-
Allure::setOutputDirectory($config->getOutputDirectory() ?? self::DEFAULT_OUTPUT_DIRECTORY);
77+
Allure::getLifecycleConfigurator()->setOutputDirectory(
78+
$config->getOutputDirectory() ?? self::DEFAULT_OUTPUT_DIRECTORY,
79+
);
7880

7981
foreach ($config->getLinkTemplates() as $linkType => $linkTemplate) {
8082
Allure::getLifecycleConfigurator()->addLinkTemplate(

src/ExceptionDetailsTrait.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
trait ExceptionDetailsTrait
1010
{
11-
1211
protected function onNotSuccessfulTest(Throwable $t): void
1312
{
1413
AllureAdapter::getInstance()->setLastException($t);

src/Internal/ConfigInterface.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
interface ConfigInterface
1212
{
13-
1413
public function getOutputDirectory(): ?string;
1514

1615
/**

src/Internal/DefaultThreadDetector.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
*/
1818
final class DefaultThreadDetector implements ThreadDetectorInterface
1919
{
20-
2120
private string|false|null $hostName = null;
2221

2322
public function getThread(): ?string

src/Internal/TestInfo.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
*/
1010
final class TestInfo
1111
{
12-
1312
/**
1413
* @param string $test
1514
* @param class-string|null $class

src/Internal/TestLifecycle.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
*/
2424
final class TestLifecycle implements TestLifecycleInterface
2525
{
26-
2726
private ?TestInfo $currentTest = null;
2827

2928
public function __construct(

0 commit comments

Comments
 (0)