A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/allure-framework/allure-phpunit/commit/1b800cdf612d4ec6e916e959a95604c91f0ba7e9 below:

test method is correctly detectied with data provider (fixes #98, via… · allure-framework/allure-phpunit@1b800cd · GitHub

File tree Expand file treeCollapse file tree 10 files changed

+170

-31

lines changed

Filter options

Expand file treeCollapse file tree 10 files changed

+170

-31

lines changed Original file line number Diff line number Diff line change

@@ -49,9 +49,17 @@ jobs:

49 49

${{ matrix.composer-options }}

50 50 51 51

- name: Run tests

52 -

if: ${{ matrix.os != 'windows-latest' }}

52 +

if: ${{ matrix.os != 'windows-latest' && !contains(matrix.composer-options, '--prefer-lowest') }}

53 53

run: composer test

54 54 55 +

- name: Run tests (lowest)

56 +

if: ${{ matrix.os != 'windows-latest' && contains(matrix.composer-options, '--prefer-lowest') }}

57 +

run: composer test-lowest

58 + 55 59

- name: Run tests (windows)

56 -

if: ${{ matrix.os == 'windows-latest' }}

60 +

if: ${{ matrix.os == 'windows-latest' && !contains(matrix.composer-options, '--prefer-lowest') }}

57 61

run: composer test-windows

62 + 63 +

- name: Run tests (windows-lowest)

64 +

if: ${{ matrix.os == 'windows-latest' && contains(matrix.composer-options, '--prefer-lowest') }}

65 +

run: composer test-windows-lowest

Original file line number Diff line number Diff line change

@@ -60,29 +60,52 @@

60 60

"scripts": {

61 61

"test-cs": "vendor/bin/phpcs -sp",

62 62

"test-unit": "vendor/bin/phpunit --coverage-text",

63 +

"test-unit-lowest": "vendor/bin/phpunit --configuration=phpunit.10.0.xml --coverage-text",

63 64

"clear-allure-results": "rm -rf ./build/allure-results",

64 65

"test-report": [

65 66

"@clear-allure-results",

66 67

"vendor/bin/paratest --processes=3 --configuration=phpunit.report.xml --testsuite=positive",

67 68

"vendor/bin/paratest --processes=3 --configuration=phpunit.report.xml --testsuite=negative; exit 0"

68 69

],

70 +

"test-report-lowest": [

71 +

"@clear-allure-results",

72 +

"vendor/bin/paratest --processes=3 --configuration=phpunit.10.0.report.xml --testsuite=positive",

73 +

"vendor/bin/paratest --processes=3 --configuration=phpunit.10.0.report.xml --testsuite=negative; exit 0"

74 +

],

69 75

"test-report-windows": [

70 76

"@clear-allure-results",

71 77

"vendor/bin/paratest --processes=3 --configuration=phpunit.report.xml --testsuite=positive",

72 78

"vendor/bin/paratest --processes=3 --configuration=phpunit.report.xml --testsuite=negative & exit 0"

73 79

],

80 +

"test-report-windows-lowest": [

81 +

"@clear-allure-results",

82 +

"vendor/bin/paratest --processes=3 --configuration=phpunit.10.0.report.xml --testsuite=positive",

83 +

"vendor/bin/paratest --processes=3 --configuration=phpunit.10.0.report.xml --testsuite=negative & exit 0"

84 +

],

74 85

"test-psalm": "vendor/bin/psalm --shepherd",

75 86

"test": [

76 87

"@test-cs",

77 88

"@test-unit",

78 89

"@test-report",

79 90

"@test-psalm"

80 91

],

92 +

"test-lowest": [

93 +

"@test-cs",

94 +

"@test-unit-lowest",

95 +

"@test-report-lowest",

96 +

"@test-psalm"

97 +

],

81 98

"test-windows": [

82 99

"@test-cs",

83 100

"@test-unit",

84 101

"@test-report-windows",

85 102

"@test-psalm"

103 +

],

104 +

"test-windows-lowest": [

105 +

"@test-cs",

106 +

"@test-unit-lowest",

107 +

"@test-report-windows-lowest",

108 +

"@test-psalm"

86 109

]

87 110

}

88 111

}

Original file line number Diff line number Diff line change

@@ -0,0 +1,25 @@

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/10.0/phpunit.xsd"

5 +

colors="true"

6 +

displayDetailsOnIncompleteTests="true"

7 +

displayDetailsOnSkippedTests="true"

8 +

displayDetailsOnTestsThatTriggerDeprecations="true"

9 +

displayDetailsOnTestsThatTriggerWarnings="true"

10 +

displayDetailsOnTestsThatTriggerNotices="true"

11 +

displayDetailsOnTestsThatTriggerErrors="true"

12 +

defaultTestSuite="positive">

13 +

<testsuites>

14 +

<testsuite name="positive">

15 +

<directory>test/report/Generate</directory>

16 +

<exclude>test/report/Generate/NegativeTest.php</exclude>

17 +

</testsuite>

18 +

<testsuite name="negative">

19 +

<file>test/report/Generate/NegativeTest.php</file>

20 +

</testsuite>

21 +

</testsuites>

22 +

<extensions>

23 +

<bootstrap class="Qameta\Allure\PHPUnit\AllureExtension" />

24 +

</extensions>

25 +

</phpunit>

Original file line number Diff line number Diff line change

@@ -0,0 +1,23 @@

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/10.0/phpunit.xsd"

5 +

colors="true"

6 +

displayDetailsOnIncompleteTests="true"

7 +

displayDetailsOnSkippedTests="true"

8 +

displayDetailsOnTestsThatTriggerDeprecations="true"

9 +

displayDetailsOnTestsThatTriggerWarnings="true"

10 +

displayDetailsOnTestsThatTriggerNotices="true"

11 +

displayDetailsOnTestsThatTriggerErrors="true"

12 +

defaultTestSuite="unit">

13 +

<testsuites>

14 +

<testsuite name="unit">

15 +

<directory>test/unit/</directory>

16 +

</testsuite>

17 +

</testsuites>

18 +

<coverage>

19 +

<include>

20 +

<directory suffix=".php">src/</directory>

21 +

</include>

22 +

</coverage>

23 +

</phpunit>

Original file line number Diff line number Diff line change

@@ -1,8 +1,14 @@

1 1

<?xml version="1.0" encoding="UTF-8"?>

2 2

<phpunit

3 3

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

4 -

xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd"

4 +

xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.1/phpunit.xsd"

5 5

colors="true"

6 +

displayDetailsOnIncompleteTests="true"

7 +

displayDetailsOnSkippedTests="true"

8 +

displayDetailsOnTestsThatTriggerDeprecations="true"

9 +

displayDetailsOnTestsThatTriggerWarnings="true"

10 +

displayDetailsOnTestsThatTriggerNotices="true"

11 +

displayDetailsOnTestsThatTriggerErrors="true"

6 12

defaultTestSuite="positive">

7 13

<testsuites>

8 14

<testsuite name="positive">

Original file line number Diff line number Diff line change

@@ -1,17 +1,26 @@

1 1

<?xml version="1.0" encoding="UTF-8"?>

2 2

<phpunit

3 3

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

4 -

xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd"

4 +

xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.1/phpunit.xsd"

5 5

colors="true"

6 +

displayDetailsOnIncompleteTests="true"

7 +

displayDetailsOnSkippedTests="true"

8 +

displayDetailsOnTestsThatTriggerDeprecations="true"

9 +

displayDetailsOnTestsThatTriggerWarnings="true"

10 +

displayDetailsOnTestsThatTriggerNotices="true"

11 +

displayDetailsOnTestsThatTriggerErrors="true"

6 12

defaultTestSuite="unit">

7 13

<testsuites>

8 14

<testsuite name="unit">

9 15

<directory>test/unit/</directory>

10 16

</testsuite>

11 17

</testsuites>

12 -

<coverage>

18 +

<source>

13 19

<include>

14 -

<directory suffix=".php">src/</directory>

20 +

<directory>src/</directory>

15 21

</include>

16 -

</coverage>

22 +

<exclude>

23 +

<directory>vendor/</directory>

24 +

</exclude>

25 +

</source>

17 26

</phpunit>

Original file line number Diff line number Diff line change

@@ -165,18 +165,26 @@ private function getCurrentTest(): TestInfo

165 165 166 166

private function buildTestInfo(string $test, ?string $host = null, ?string $thread = null): TestInfo

167 167

{

168 -

$dataLabelMatchResult = preg_match(

169 -

'#^([^\s]+)\s+with\s+data\s+set\s+(\#\d+|".+")\s+\(.+\)$#',

168 +

/** @var list<string> $matches */

169 +

$classAndMethodMatchResult = preg_match(

170 +

'#^(\S+)(.*)$#',

170 171

$test,

171 172

$matches,

172 173

);

173 - 174 -

/** @var list<string> $matches */

175 -

if (1 === $dataLabelMatchResult) {

176 -

$classAndMethod = $matches[1] ?? null;

177 -

$dataLabel = $matches[2] ?? '?';

178 -

} else {

179 -

$classAndMethod = $test;

174 +

[$classAndMethod, $dataSetInfo] = 1 === $classAndMethodMatchResult

175 +

? [$matches[1] ?? null, $matches[2] ?? null]

176 +

: [$test, null];

177 +

$dataLabelMatchResult = isset($dataSetInfo)

178 +

? preg_match(

179 +

'/^\s+with\s+data\s+set\s+(?:(#\d+)|"(.*)")$/',

180 +

$dataSetInfo,

181 +

$matches,

182 +

)

183 +

: false;

184 +

$dataLabel = 1 === $dataLabelMatchResult

185 +

? $matches[2] ?? $matches[1] ?? null

186 +

: null;

187 +

if ('' === $dataLabel) {

180 188

$dataLabel = null;

181 189

}

182 190 Original file line number Diff line number Diff line change

@@ -0,0 +1,44 @@

1 +

<?php

2 + 3 +

declare(strict_types=1);

4 + 5 +

namespace Qameta\Allure\PHPUnit\Test\Report\Generate;

6 + 7 +

use PHPUnit\Framework\Attributes\DataProvider;

8 +

use PHPUnit\Framework\TestCase;

9 +

use Qameta\Allure\Allure;

10 +

use Qameta\Allure\Attribute\DisplayName;

11 + 12 +

class DataProviderTest extends TestCase

13 +

{

14 +

#[DataProvider('providerNamed'), DisplayName('Test with named data set')]

15 +

public function testNamedDataSet(int $x, int $y): void

16 +

{

17 +

Allure::runStep(fn () => self::assertSame($x, $y));

18 +

}

19 + 20 +

public static function providerNamed(): iterable

21 +

{

22 +

return [

23 +

'Simple name' => [1, 1],

24 +

'' => [2, 2],

25 +

'"Double-quoted" name' => [3, 3],

26 +

"'Single-quoted' name" => [4, 4],

27 +

' ' => [5, 5],

28 +

];

29 +

}

30 + 31 +

#[DataProvider('providerListed')]

32 +

public function testListedDataSet(int $x, int $y): void

33 +

{

34 +

Allure::runStep(fn () => self::assertSame($x, $y));

35 +

}

36 + 37 +

public static function providerListed(): iterable

38 +

{

39 +

return [

40 +

[1, 1],

41 +

[2, 2],

42 +

];

43 +

}

44 +

}

Original file line number Diff line number Diff line change

@@ -4,13 +4,17 @@

4 4 5 5

namespace Qameta\Allure\PHPUnit\Test\Report\Generate;

6 6 7 -

use PHPUnit\Event;

7 +

use PHPUnit\Framework\Attributes\DoesNotPerformAssertions;

8 8

use PHPUnit\Framework\TestCase;

9 9

use Qameta\Allure\Allure;

10 10

use Qameta\Allure\Attribute\DisplayName;

11 11

use Qameta\Allure\PHPUnit\ExceptionDetailsTrait;

12 12

use RuntimeException;

13 13 14 +

use function trigger_error;

15 + 16 +

use const E_USER_WARNING;

17 + 14 18

class NegativeTest extends TestCase

15 19

{

16 20

use ExceptionDetailsTrait;

@@ -51,22 +55,10 @@ function () {

51 55

);

52 56

}

53 57 54 -

#[DisplayName('Test that emits warning is reported as broken')]

58 +

#[DisplayName('Test that emits warning is reported as broken'), DoesNotPerformAssertions]

55 59

public function testWarning(): void

56 60

{

57 -

/**

58 -

* @psalm-suppress InternalMethod

59 -

* @psalm-suppress InternalClass

60 -

* @psalm-suppress TooManyArguments

61 -

*/

62 -

Event\Facade::emitter()->testTriggeredWarning(

63 -

$this->valueObjectForEvents(),

64 -

"Test triggered warning",

65 -

__FILE__,

66 -

__LINE__,

67 -

false,

68 -

);

69 -

self::assertTrue(true);

61 +

trigger_error('"Test triggered warning"', E_USER_WARNING);

70 62

}

71 63 72 64

#[DisplayName('Skipped test is reported as skipped')]

Original file line number Diff line number Diff line change

@@ -261,6 +261,7 @@ protected function createTestWarningTriggeredEvent(

261 261

'file',

262 262

1,

263 263

false,

264 +

false,

264 265

);

265 266

}

266 267

}

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4