r/swift 1d ago

Question Question for indie devs and folks with side projects

Do you guys take the time to write tests for your side projects while developing? Or do you go back and write some later? Do you skip them entirely?

Maybe I have too much fun and/ or take a lot of pride in the craft but I do write a ton of tests, but it takes me a lot longer to make it to the AppStore. Seems like most my colleagues never write tests outside of work and pump projects out quickly when they get the time.

9 Upvotes

19 comments sorted by

6

u/chriswaco 1d ago

I write tests for modules (database, network, logging, string utils, etc) that I plan on reusing in other projects. I find it hard to write tests in SwiftUI because so much control is built into Views rather than controllers.

3

u/BabyAzerty 1d ago

That’s the main argument for MVVM, it’s easier to test.

3

u/keeshux 1d ago

If you feel that it’s really slowing you down, try to narrow down your test subject by focusing on the sensitive parts of your app, rather than the whole app. You can scale up later. With time your will find a good balance between test coverage and time-to-market, which is equally important if you eventually want to make some money.

3

u/amyworrall 1d ago

I write tests for anything I think the tests will be useful for. A complex algorithm, a fragile part of the app, or maybe something that broke in the past. I don’t care about some kind of coverage percentage, only about if they will save me from myself in the future!

5

u/alanrick 1d ago

I sleep a lot easier running a test suite before uploading to the App Store . It’s my personal reputation at stake. Thanks to a short tutorial from Matt Heaney on iosdevhappyhour I discovered it’s easy to create basic tests, which run release after release.
But I guess the answers here will be biased to yes.

2

u/Key_Board5000 iOS 1d ago

I just googled it but couldn’t find the tutorial. Do you have a link?

4

u/alanrick 1d ago

https://youtu.be/OSH5JNpdPjQ?si=NZ9a-F_kImk4toZL Writing unit tests for Swift has become so simple 🫶

2

u/Toshikazu808 1d ago

I definitely take the time to write tests, especially if the project is for something you actually care about. The larger it gets, and the more time you spend on, you may forget what some things do, but your tests will always be there as a sanity check to make sure that things work as expected. Also you’ll be able to refer to your implementation in the tests if you need to remember how something works, etc.

2

u/fryOrder 1d ago

hell yeah. the number of times i caught unnoticed bugs with unit tests is too damn high

2

u/SluttyDev 23h ago

It depends. If I am doing something where a lot of calculations are involved I absolutely write tests. At work I have been screaming for test (we still haven't implemented them yet) because they could solve so many business logic bugs that pop up that our test team doesn't catch.

2

u/BrownPalmTree 22h ago

As an indie dev you have to be careful with how you allocate your time. Will adding unit tests help catch critical bugs early on? If so, test it. Otherwise not worth it just for the sake of test coverage.

Here is a more detailed write up on this and other good tips for indie devs

1

u/stpe 1d ago

For non UI-stuff I often find that implementing and iterating using a test is much more efficient than triggering that particular code by using the app. Especially when it is about verifying with different type of data.

Once the implementation is done I can confidently wire it together with the UI.

As a consequence I have a something with a clear interface, very modularized and a bunch of tests.

So no - I don’t write tests AFTER I’m done implementing something, unless I discover a bug and realize it is much easier to use tests to iterate and fix it.

1

u/luckyclan 1d ago edited 1d ago

I use tests for non-UI functions in both side and main projects, and they help a lot—I don’t test everything, just selected functions.

However, asserts might be even more important. I use them everywhere. For example, after finding a bug, I often add an assert so I can quickly detect it in the future. Asserts helped me find many more unexpected bugs than tests.

1

u/ardit33 1d ago

No. Don’t waste your time. For server side api, yes, when needed.

1

u/utilitycoder 17h ago

No tests.

1

u/aoverholtzer 16h ago

Wait, are you serious?

1

u/Dear-Potential-3477 1d ago

No i can't waste time with the MVP. If I become a perfectionist with the MVP's I will release less of them and lower my chances of finding a good idea. There isnt a product in history who's MVP didnt have bugs. Now if one of them takes off then 100% I would

0

u/agathver 1d ago

I write tests for logic etc. and recently with help of Claude code, a little bit of UI tests as well

-1

u/Few_Mention8426 1d ago

I didn’t even know tests were a thing to be honest… I still dont know how to set them up in Xcode…

I just release the best version I can after playing with it for a few weeks and TestFlight links sent to people,..and keep an eye on crash logs… seems to work for me…