Skip to content
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

Add PHPUnit data provider set name to output filenames #1084

Merged
merged 7 commits into from
Feb 9, 2024

Conversation

ziadoz
Copy link
Contributor

@ziadoz ziadoz commented Feb 8, 2024

If there's a failure in a Dusk test case that uses PHPUnit data providers, then only a screenshot of the last data set that failed will be available in the screenshots directory. This is because without the data set in the filename, each new screenshot overwrites the previous one.

This PR adds the data set, where applicable, to the filenames of screenshots and console output:

With no data provider:

failure-Tests_Browser_FooTest_test_without_data-0.png

With unnamed data set (0, 1):

failure-Tests_Browser_FooTest_test_with_data_0-0.png
failure-Tests_Browser_FooTest_test_with_data_1-0.png

With named data set (foo, bar):

failure-Tests_Browser_FooTest_test_with_named_data_foo-0.png
failure-Tests_Browser_FooTest_test_with_named_data_bar-0.png

I've retained the existing 140 character filename limit by trimming it off the left hand side of the filename, so namespaces are truncated.

Copy link

github-actions bot commented Feb 8, 2024

Thanks for submitting a PR!

Note that draft PR's are not reviewed. If you would like a review, please mark your pull request as ready for review in the GitHub user interface.

Pull requests that are abandoned in draft may be closed due to inactivity.

@ziadoz ziadoz marked this pull request as ready for review February 9, 2024 11:19
@taylorotwell
Copy link
Member

taylorotwell commented Feb 9, 2024

Can we make the PR not change the names of screenshots for tests that use no data set?

@taylorotwell taylorotwell marked this pull request as draft February 9, 2024 15:15
@ziadoz
Copy link
Contributor Author

ziadoz commented Feb 9, 2024

@taylorotwell I've pushed a test to prove the filenames are unchanged if there's no data set.

);
$browsers = collect([$browser]);

$this->storeConsoleLogsFor($browsers);
}

public static function testData()
public static function data()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took the test prefix off of this because PHPUnit is running the method as a test.

@ziadoz ziadoz marked this pull request as ready for review February 9, 2024 15:42
@taylorotwell taylorotwell merged commit f6d718d into laravel:7.x Feb 9, 2024
22 checks passed
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 this pull request may close these issues.

None yet

2 participants