swiftlang / swiftlang/swift-testing
Ability to write tests right in the same file
Nobody has claimed this yet.
- Dominant language
- Swift
- Stars
- 2.2k
- Forks
- 169
- Avg merge
- 1d 18h
- Merged PRs (30d)
- 56
Description
Description
It would be nice if we had the ability to write test in the same file, and not in files far away in a dedicated Tests folder.
This will have some benefits like:
- The code and the tests are just simply closer apart.
- We could use access modifiers like
fileprivateto test parts of the code in the same file, instead of having to workaround this by@testableimporting which makes users have to not useprivateaccess modifiers just to be able to test a function. Or using stuff like@_spi.
Languages like Rust do support this.
I saw some discussions about this a few months ago, I think the compiler needs to support better discovery of stuff like tests for this to be possible.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the issue's referenced discussions about placing tests in the same Swift source file and the compiler's test discovery limitations. Define how same-file tests should be discovered and how access modifiers such as fileprivate should behave; the work is done when the requested capability is supported and its behavior is verified.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- testing
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100