Skip to content

Commit

Permalink
Extension rewritten for PHPUnit 10 (allure-framework#85)
Browse files Browse the repository at this point in the history
  • Loading branch information
remorhaz committed Sep 18, 2023
1 parent 17d2a8a commit ed96c3e
Show file tree
Hide file tree
Showing 45 changed files with 1,337 additions and 617 deletions.
18 changes: 4 additions & 14 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ jobs:
fail-fast: false
matrix:
php-version:
- "8.0"
- "8.1"
- "8.2"
- "8.3"
os:
- ubuntu-latest
- windows-latest
Expand All @@ -29,7 +29,7 @@ jobs:
- "--prefer-lowest"
steps:
- name: Checkout
uses: actions/checkout@v3.5.0
uses: actions/checkout@v3

- name: Validate composer.json and composer.lock
run: composer validate
Expand All @@ -49,19 +49,9 @@ jobs:
${{ matrix.composer-options }}

- name: Run tests
if: ${{ matrix.os != 'windows-latest' && matrix.php-version != '8.2' }}
if: ${{ matrix.os != 'windows-latest' }}
run: composer test

- name: Run tests (windows)
if: ${{ matrix.os == 'windows-latest' && matrix.php-version != '8.2' }}
run: composer test-windows

- name: Run tests (experimental)
if: ${{ matrix.os != 'windows-latest' && matrix.php-version == '8.2' }}
continue-on-error: true
run: composer test

- name: Run tests (windows, experimental)
if: ${{ matrix.os == 'windows-latest' && matrix.php-version == '8.2' }}
continue-on-error: true
if: ${{ matrix.os == 'windows-latest' }}
run: composer test-windows
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,25 +34,25 @@ This adapter only generates JSON files containing information about tests. See [

## Installation && Usage
**Note:** this adapter supports Allure 2.x.x only.

Supported PHP versions: 8.1-8.3.

In order to use this adapter you need to add a new dependency to your **composer.json** file:
```
{
"require": {
"php": "^8",
"allure-framework/allure-phpunit": "^2"
"php": "^8.1",
"allure-framework/allure-phpunit": "^3"
}
}
```
Then add Allure test listener in **phpunit.xml** file:
```xml
<extensions>
<extension class="Qameta\Allure\PHPUnit\AllureExtension">
<!-- Optional arguments block; omit it if you want to use default values -->
<arguments>
<!-- Path to config file (default is config/allure.config.php) -->
<string>config/allure.config.php</string>
</arguments>
</extension>
<bootstrap class="Qameta\Allure\PHPUnit\AllureExtension">
<!-- Path to config file (default is config/allure.config.php) -->
<parameter name="config" value="config/allure.config.php" />
</bootstrap>
</extensions>
```
Config is common PHP file that should return an array:
Expand Down Expand Up @@ -84,17 +84,17 @@ After running PHPUnit tests a new folder will be created (**build/allure-results
This adapter comes with a set of PHP annotations and traits allowing to use main Allure features.

### Human-readable test class or test method title
In order to add such title to any test class or [test case](https://github.com/allure-framework/allure1/wiki/Glossary#test-case) method you need to annotate it with **#[Title]** annotation:
In order to add such title to any test class or [test case](https://github.com/allure-framework/allure1/wiki/Glossary#test-case) method you need to annotate it with **#[DisplayName]** annotation:
```php
namespace Example\Tests;

use PHPUnit\Framework\TestCase;
use Qameta\Allure\Attribute\Title;
use Qameta\Allure\Attribute\DisplayName;

#[Title("Human-readable test class title")]
#[DisplayName("Human-readable test class title")]
class SomeTest extends TestCase
{
#[Title("Human-readable test method title")]
#[DisplayName("Human-readable test method title")]
public function testCaseMethod(): void
{
//Some implementation here...
Expand Down Expand Up @@ -251,7 +251,7 @@ class SomeTest extends TestCase
Title("Second step"),
Parameter("param2", "value2"),
]
private function stepTwo()
private function stepTwo(): void
{
//Some implementation here...
}
Expand Down
25 changes: 11 additions & 14 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,19 @@
"source": "https://github.com/allure-framework/allure-phpunit"
},
"require": {
"php": "^8",
"php": "~8.1.0 || ~8.2.0 || ~8.3.0",
"allure-framework/allure-php-commons": "^2",
"phpunit/phpunit": "^9"
"phpunit/phpunit": "^10"
},
"require-dev": {
"brianium/paratest": "^6.8",
"brianium/paratest": "^7",
"psalm/plugin-phpunit": "^0.18.4",
"squizlabs/php_codesniffer": "^3.7.1",
"vimeo/psalm": "^5.4"
"squizlabs/php_codesniffer": "^3.7.2",
"vimeo/psalm": "^5.15"
},
"conflict": {
"amphp/byte-stream": "<1.5.1"
"amphp/byte-stream": "<1.5.1",
"brianium/paratest": "<7.0.3"
},
"autoload": {
"psr-4": {
Expand All @@ -63,27 +64,23 @@
"test-report": [
"@clear-allure-results",
"vendor/bin/paratest --processes=3 --configuration=phpunit.report.xml --testsuite=positive",
"vendor/bin/paratest --processes=3 --configuration=phpunit.report.xml --testsuite=negative; exit 0",
"vendor/bin/paratest --processes=3 --configuration=phpunit.report.xml --testsuite=retries --repeat=3; exit 0"
"vendor/bin/paratest --processes=3 --configuration=phpunit.report.xml --testsuite=negative; exit 0"
],
"test-report-windows": [
"@clear-allure-results",
"vendor/bin/paratest --processes=3 --configuration=phpunit.report.xml --testsuite=positive",
"vendor/bin/paratest --processes=3 --configuration=phpunit.report.xml --testsuite=negative & exit 0",
"vendor/bin/paratest --processes=3 --configuration=phpunit.report.xml --testsuite=retries --repeat=3 & exit 0"
"vendor/bin/paratest --processes=3 --configuration=phpunit.report.xml --testsuite=negative & exit 0"
],
"test-psalm": "vendor/bin/psalm --shepherd",
"test": [
"@test-cs",
"@test-unit",
"@test-report",
"@test-psalm"
"@test-report"
],
"test-windows": [
"@test-cs",
"@test-unit",
"@test-report-windows",
"@test-psalm"
"@test-report-windows"
]
}
}
8 changes: 2 additions & 6 deletions phpunit.report.xml
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd"
colors="true"
defaultTestSuite="positive">
<testsuites>
<testsuite name="positive">
<directory>test/report/Generate</directory>
<exclude>test/report/Generate/NegativeTest.php</exclude>
<exclude>test/report/Generate/RetriesTest.php</exclude>
</testsuite>
<testsuite name="negative">
<file>test/report/Generate/NegativeTest.php</file>
</testsuite>
<testsuite name="retries">
<file>test/report/Generate/RetriesTest.php</file>
</testsuite>
</testsuites>
<extensions>
<extension class="Qameta\Allure\PHPUnit\AllureExtension" />
<bootstrap class="Qameta\Allure\PHPUnit\AllureExtension" />
</extensions>
</phpunit>
4 changes: 2 additions & 2 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd"
colors="true"
defaultTestSuite="unit">
<testsuites>
<testsuite name="unit">
<directory>test/unit/</directory>
</testsuite>
</testsuites>
<coverage processUncoveredFiles="true">
<coverage>
<include>
<directory suffix=".php">src/</directory>
</include>
Expand Down
4 changes: 4 additions & 0 deletions psalm.xml.dist
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<?xml version="1.0"?>
<psalm
errorLevel="1"
findUnusedBaselineEntry="true"
findUnusedCode="false"
findUnusedPsalmSuppress="false"
findUnusedVariablesAndParams="false"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd">
Expand Down
Loading

0 comments on commit ed96c3e

Please sign in to comment.