-
-
Notifications
You must be signed in to change notification settings - Fork 10
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
[Feature Request]: Adding Test Codes #29
Comments
This is something that I've been wanting to do for a while, but have keep pushing it back because I don't know where to start. More specifically, I need to better understand how to mock data, which is something I've always been weak at. But you're absolutely correct that this needs to be done and I'll make it more of a priority in the coming days. As for Swift Testing, as you've mentioned, it's mainly available for Swift 6. Please note that ATProtoKit doesn't fully support Swift 6 yet: while it builds (according to Swift Package Index), there are some race-related errors according to the service. I'm more than happy to have you help in writing unit tests via Swift Testing. That will remove a lot of pressure off of me, so thank you for your willingness to help. I'm tempted to say that we can use XCTest and Swift Testing at the same time (since, as far as I'm concerned, XCTest works on non-Apple platforms as well and it'll work with Swift 5.9), but that might be too much work. For now though, we'll simply stick to Swift Testing and we'll see what additional options we'll have. I also share your concerns about writing too many unit tests. They will have to be thoughtful but still expansive enough. |
I understood that we are going to try using Swift Testing. I will write as many tests as I can with the Swift Testing framework to familiarize myself with it before making a pull request. Finally, I would like your opinion on how far to go with the test after it is ready. In the meantime, I'm going to do the following.
|
Take as much time as you need: I'll leave it up to you, and then I'll refine as we go along. We'll need to mock the data since testing using online requests would be a bad idea. Due to this, I'll open up With respect to my opinion on how far to go with the tests after it's ready, that's a little bit of an unknown answer. What I mean to say is, I don't know how to fully answer this question, as I haven't thought too deeply into how far it should go. However, What I would like to see so far are the following:
That's about everything I can think of right at this moment. I'll think of others as time goes on, but again, it should be thoughtful but expansive. Please take as long as you need. If you need breaks, please do so. You're not obligated to do this, but again, I appreciate taking time off of your busy schedule to do this. |
Summary
By adding test code, you can verify that the code works properly. It is also possible to find defects.
Pain points
Currently, you have to check whether a program is operating according to specifications, whether it is due to your implementation, or whether it is due to a bug.
This feature will make it easier to check the general operating status.
Considered Alternatives
With this method, each person needs to write and check the code to confirm that it works. Note that this is an inconsistent operation check. It also requires time and effort to write documentation. Once the test code is implemented, there is no need for everyone to write the code again.
Is this a breaking change?
No
Library Examples
No response
Additional Context
The following items would need to be considered
I think it should be done when the framework design is finalized. We do not want to rewrite the test code too often.
In my opinion, it is sufficient to test that it can be executed without throwing errors and that it returns values. I am concerned that writing too much test code will make it difficult to maintain.
I think Swift Testing is the best choice for this package, but the problem is that the official version supports Swift 6.0 or later. There may be an option to use other open source testing frameworks.
If you choose to implement this using Swift Testing, I would be happy to write this code, even though I know it is not perfect.
The text was updated successfully, but these errors were encountered: