OK, so it took longer than expected to create this topic. But I guess it is still OK as we already applied as an organization?
Anyway, as mentioned in this topic, what I would like to pitch is that we use GSoC to accelerate progress on swift-testing: in my opinion of the most important projects currently underway in the Swift ecosystem as improvements to testability benefit everyone.
So, these are the things I was thinking about as possible improvements:
1 Use a closure for the test code (instead of having to make - and name - a function)
2 Nicer test output
3 Easier integration for test doubles
4 Testing fatalError, assert, precondition (has its own thread )
Ad 1. Swift Testing uses the following syntax:
@Test("Some description of the test, i.e. some Gherkin text or anything else") func actualFunctionName() { // your test code here }
Using the description to name the test is very convenient. It is close to BDD style test frameworks and is versatile in that it supports anything a String supports. However, naming the function is somewhat inconvenient. If you are like me, you more or less copy_the_description_in_snake_case. It would be an improvement if you could define a test as a closure:
@Test("Your description here") { // your test code }
Ad 2 Nicer test output
Swift Testing uses XCTest under the hood, which means that tests report a big wall of text. Finding the failed test can take some searching, especially as there is no coloring or anything. And there isn't even a list of tests that failed.
Ideally, we'd have something like Jest
that provides a very nice view of test results. And when tests fail, which test failed and where it failed. Add in features to 'watch' for code changes and automatically rerun failed tests. Very nice. Makes TDD in JavaScript/TypeScript very fast and with minimal friction.
Could we create something like this? Perhaps we can't rebuild XCTest, but do something to make parsing the results easier?
Ad 3. Easier integration of test doubles
This one came up in the forum post a few times. This is not my field of expertise, so I hope others can chime in. What I do know is that I too have a lot of problems effectively testing UI, testing notifications and testing frameworks such as CloudKit.
Ad 4. Testing fatalError and friends
There is a whole forum topic associated with this issue. It describes both the issue (i.e. can't test code paths that trigger these functions) as well as potential solutions. Or workarounds typically. Personally, I am of the opinion that a convenient way of testing these functions would help in safely using these functions where they are applicable.
Anyway, these are the projects I collected earlier. I can imagine there are way more opportunities where we can benefit from accelerating swift-testing. So please chime in, using this topic.
Cheers, Maarten