-
- Notifications
You must be signed in to change notification settings - Fork 2.2k
Closed
Labels
feature/data-providerData ProvidersData Providersfeature/test-runnerCLI test runnerCLI test runnertype/enhancementA new idea that should be implementedA new idea that should be implementedversion/10Something affects PHPUnit 10Something affects PHPUnit 10version/11Something affects PHPUnit 11Something affects PHPUnit 11version/12Something affects PHPUnit 12Something affects PHPUnit 12
Description
| Q | A |
|---|---|
| PHPUnit version | 12.4-dev |
| PHP version | 8.4.11 |
| Installation Method | Composer |
Summary
A data provider method causes a warning about Risky test (This test did not perform any assertions)
How to reproduce
This is my two methods, test and data:
<?php declare(strict_types=1); use Dotclear\Helper\Html\WikiToHtml; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; class WikiToHtmlTest extends TestCase { ... /* previous test methods */ … public static function testTagTransformProvider(): array { return [ ['em', ["''", "''"]], ['strong', ['__', '__']], ['abbr', ['??', '??']], ['q', ['{{', '}}']], ['code', ['@@', '@@']], ['del', ['--', '--']], ['ins', ['++', '++']], ['mark', ['""', '""']], ['sup', ['^', '^']], ['sub', [',,', ',,']], ['i', ['££', '££']], ['span', [';;', ';;']], ]; } #[DataProvider('testTagTransformProvider')] public function testTagTransform(string $tag, array $delimiters): void { $wiki = new WikiToHtml(); $phrase = 'Dotclear do blog and do it well'; $this->assertSame( sprintf('<p>Before <%1$s>%2$s</%1$s> After</p>', $tag, $phrase), $wiki->transform(sprintf('Before %s%s%s After', $delimiters[0], $phrase, $delimiters[1])) ); $this->assertSame( sprintf('<p><%1$s>%2$s</%1$s></p>', $tag, $phrase), $wiki->transform(sprintf('%s%s%s', $delimiters[0], $phrase, $delimiters[1])) ); } }And the output is:
PHPUnit 12.4-dev by Sebastian Bergmann and contributors. Runtime: PHP 8.4.11 with Xdebug 3.4.0 Configuration: /Users/.../git-dc/phpunit.dist.xml .............R... 17 / 17 (100%) Time: 00:00.309, Memory: 79.00 MB There was 1 risky test: 1) WikiToHtmlTest::testTagTransformProvider This test did not perform any assertions /Users/.../git-dc/tests/unit/src/Helper/Html/WikiToHtmlTest.php:233 OK, but there were issues! Tests: 17, Assertions: 36, Risky: 1. Generating code coverage report in HTML format ... done [00:00.122] Expected behavior
Don't warn about data provider static method as Risky? Or may be I'm doing something wrong ?
Metadata
Metadata
Assignees
Labels
feature/data-providerData ProvidersData Providersfeature/test-runnerCLI test runnerCLI test runnertype/enhancementA new idea that should be implementedA new idea that should be implementedversion/10Something affects PHPUnit 10Something affects PHPUnit 10version/11Something affects PHPUnit 11Something affects PHPUnit 11version/12Something affects PHPUnit 12Something affects PHPUnit 12