Skip to content

Document the support for replacing placeholders in @testdox text with data provider values #218

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
sebastianbergmann opened this issue Mar 18, 2021 · 0 comments

Comments

@sebastianbergmann
Copy link
Owner

It would be good to document @ https://phpunit.readthedocs.io/en/9.5/annotations.html?highlight=testdox#testdox that one can also use $_dataName in the @testDox line, and it's the value of the key from the data provider's array, ie:

/**
@testDox $_dataName ($testCase)
@dataProvider provideCases
*/
function testSomething($testValue) {
    // etc
}

function provideCases() {
    return [
        'testing an OK value' => ['testValue' => 42],
        'testing a bad value' => ['testValue' => -1]
    ];
}

Yields this sort of thing in the test output:

* testing an OK value (42)
* testing a bad value (-1)

It would also be good to document the @testDox usage at https://phpunit.readthedocs.io/en/9.3/writing-tests-for-phpunit.html#data-providers, given it's reasonably closely related to some of the other documented functionality there.

(Mostly putting this here in case someone lands here from a search, wondering how to leverage that key name in the @testDox line.

Originally posted by @adamcameron in sebastianbergmann/phpunit#3196 (comment)

@sebastianbergmann sebastianbergmann changed the title It would be good to document @ https://phpunit.readthedocs.io/en/9.5/annotations.html?highlight=testdox#testdox that one can also use $_dataName in the @testDox line, and it's the value of the key from the data provider's array, ie: Document the support for replacing placeholders in @testdox text with data provider values Mar 18, 2021
plucht added a commit to plucht/phpunit-documentation-english that referenced this issue Aug 5, 2021
plucht added a commit to plucht/phpunit-documentation-english that referenced this issue Aug 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant