-
Notifications
You must be signed in to change notification settings - Fork 77
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
Make it easier to run large number of serial tests #683
Comments
Could you help us to understand the scenarios you're thinking of? |
Sure, imagine you have a Vapor app using the repository pattern. Most of the tests only test business logic without any external dependencies so can be run in parallel without any issue. The integration tests for the database layer however all touch a real database so need to be run in serial otherwise those tests could overwrite one enough. Currently there isn't an ideal solution to run these tests. You either need to run the integration tests separately with (Correct me if I'm wrong but I can't extend a type that's annotated with the |
Extensions to suite types are permitted—you just can't put the @Suite("My name is Batman!") extension S {}
@Suite("No, it's Mr. Freeze!") extension S {} But you can absolutely put tests in extensions to suites, or even nest them. So you could have: @Suite(.serialized) struct DatabaseTests {}
extension DatabaseTests {
@Suite struct ReadingTests {
...
}
}
extension DatabaseTests {
@Suite struct WritingTests {
...
}
} And all three top-level declarations (the suite type and its two extensions) can go in separate files. I hope that helps! |
Oh awesome - so just to confirm |
To document that pattern better, I filed #686 |
Correct—everything inside If you find that is not the case, that's a bug, so please let us know! |
Given that we believe this pattern already exists and works, let's close this. Feel free to reopen if you find that it isn't working as described. |
Description
Something that's cropped up recently and open for discussion!
There are a number of scenarios where you might need to run tests serially, especially when it comes to integration tests (for example running tests against a real database). Currently, with Swift Testing you only have two options to accommodate this, both of which have drawbacks:
--no-parallel
- this is problematic if you have different tests you want to run as well that can be run in parallel.serialized
trait - if you have lots of tests you end up with a giant test file that's difficult to maintain. You can still have multiple suites that are marked as serialized, but whilst the tests inside them will be serial, the suites themselves will not, causing clashes.It would be great to have a better solution to handle use cases like this, either some kind of new trait or flag
-no-parallel-serial-tests
etc.Expected behavior
No response
Actual behavior
No response
Steps to reproduce
No response
swift-testing version/commit hash
No response
Swift & OS version (output of
swift --version && uname -a
)No response
The text was updated successfully, but these errors were encountered: