-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Add @group Others
to all other tests
#6770
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 @group Others
to all other tests
#6770
Conversation
7f1b741
to
82cbe97
Compare
Can you explain more about what makes us happy with the tagging? I don't get what is consistency, and what is good. I don't understand the meaning of the tag for others. |
This is what I'm trying to do with the phpunit tests:
<testsuites>
<testsuite name="AutoReview">
<directory>./tests/AutoReview</directory>
</testsuite>
<testsuite name="System">
<directory>./tests/system</directory>
<exclude>./tests/system/Database</exclude>
</testsuite>
<testsuite name="Database">
<directory>./tests/system/Database</directory>
</testsuite>
</testsuites> The idea is |
82cbe97
to
f9051da
Compare
It seems to me the initial solution is better than tagging to other test files. I put But they are tests for commands, not databases. |
How is it difficult. You just need one line each. And there's an auto-review to remind you that it needs the group.
Running
I don't agree. Those tests are there but incidentally they need DB connections, so that's why you group them. No need to move them. |
I see. Okay, tagging is more flexible than using folders. If we automate it, it would be nice if php-cs-fixer adds it. I think Others or Other is better. |
For php-cs-fixer, there's currently no built-in fixer for that except for a fixer that adds a |
Rector could add it pretty easily. I like "other" or "core" for names. Please don't use "unit tests" on anything that requires infrastructure and is actually an integration test. Bigger picture... if the real issue is just that these Command tests break the organization: why don't we mock the dependency in those tests specifically (and in anything that "needs" a live connection)? |
It seems not flexible. It means all live database tests must be in the What if we need live Cache tests with different versions of Cache servers? |
Are we being too rigid about our folder structure? Ideally tests target a single logical unit (which may span classes). If they are deterministic and self-contained then they are unit tests, if they rely on infrastructure service integration they are integration tests. This seems like a good starting point for a directory structure and baseline grouping, then we can use tags or subfolders to indicate which infrastructure components (database, system clock, cache, etc) are needed "live" as we care about them. Theoretically that would save us from needing an "other" category altogether. |
My issue is not limited to command tests. There are others too, like HTTP tests. Those do not need DB connections. In terms of testing infrastructure, I would say CI4 has a rather unconventional directory structure. My expectations were:
|
Yeah, where does the |
The Dark Ages 🙃 I am happy for us to take a pass at restructuring, especially if it is for the sake of improving our test accuracy. I'm reading this book right now and my two big takeaways from the testing section (both of which I am guilty of) are:
Number 2 gets a little murky when you are testing a framework 🫢 but I think there are still some good takeaways and I would like our structure to encourage those behaviors. |
f9051da
to
4ac0d68
Compare
@group UnitTest
to all other tests@group Others
to all other tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not going to flip through all of these but I'm on board with the approach.
Description
Since we have
DatabaseLive
,CacheLive
,SeparateProcess
,AutoReview
groups already, I think we need a catch-all group for the others for consistency.Use case: Since there are existing groups already for tests, I find that useful for my refactoring of the phpunit tests to be more efficient. The drawback is that not all tests have groups, which would unnecessarily add logic of excluding groups instead of adding group.
If you have a better term for the other group, I'm all ears.
In a separate PR, I'll add an autoreview test to enforce groups.
Checklist: