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

[Bug]: Overriding parent tests gives TestCaseAlreadyInUse #1303

Open
riabiy opened this issue Oct 19, 2024 · 2 comments
Open

[Bug]: Overriding parent tests gives TestCaseAlreadyInUse #1303

riabiy opened this issue Oct 19, 2024 · 2 comments
Labels

Comments

@riabiy
Copy link

riabiy commented Oct 19, 2024

What Happened

Hi. I can be missing something and I believe it's a bug, nevertheless.
Any attempt to override any parent test class gives me TestCaseAlreadyInUse.

Same thing happens both for pest()->extend(SpecificTestCase::class) in the test file and in the Pest.php file.

How to Reproduce

//Pest.php

pest()->extend(DuskTestCase::class)->in('Browser');
//can be in the Specific/AnyTest.php or in the Pest.php, both give same result
pest()->extend(SpecificDuskTestCase::class)->in('Browser/Tests/Specific'); 

Sample Repository

No response

Pest Version

3.4.1

PHP Version

8.3.7

Operation System

macOS

Notes

If this is the desired behaviour, what is the recommended way to override parent class for very-very 1-time niche cases?
In PHPUnit it's just vanilla PHP.
Creating a folder with "PestCanNotOverridePlaceHere" is a bit meh and not Laravelish enough, IMHO.

@riabiy riabiy added the bug label Oct 19, 2024
@riabiy
Copy link
Author

riabiy commented Oct 19, 2024

Could be a duplicate of #1109 and related to #765.

@riabiy
Copy link
Author

riabiy commented Nov 10, 2024

The issue persists. I'm not demanding anything by any means, just want to understand, if it's a design decision and, if so, what is the way to have DatabaseMigration on some tests and LazyRefreshDatabase on tests in the same folder?
They belong to the same scope, domain, etc. Just sometimes in rare cases we care about order of IDs to make snapshot smoke tests easier.

And, overall, it was something, that was working just fine in PHPUnit (due to the class-based approach), so I assume we want PestPHP to behave the same to make it a drag-n-drop replacement with better syntax. Unless I'm missing something.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant