I’m an SDE II with 9 yoe / TC 250K and have spent my whole career doing iOS and Android development. I had never written a single unit test / integration test / UI test until about a year ago when I joined Amazon because the build automatically breaks if code coverage drops for any change. I’ve always relied on manual testing for all apps I’ve written, and I feel like it has worked out fairly well because I’ve been able to create some very high quality apps. I am struggling with imposters syndrome because every other developer seems to write unit tests without thinking twice about it. For me, I only write them to keep the pipeline from breaking. It takes me twice as long to write the tests as it does to write the code, and feels like a total waste of time. I’ve never actually had a test “save me” from introducing a bug. Often my changes will break existing tests, but not because I broke anything, so I just end up having to refactor the test. Does anyone else feel this way?
You’ll get better at it with time.
I think I will get better at actually writing them more quickly with a little more practice. The bigger problem is I have yet to see the value of them. How many times have unit tests helped you prevented a bug from being introduced? So far, zero times for me.
You don't understand half the point of unit tests then. If someone else modifies the code later and introduces an unexpected behavior, your unit test will catch it.
Yikes
What is there even to struggle with? Just use assertEquals everywhere and @Test(expected=whateverException) occasionally
There are some nontrivial situations for sure. Creating mocks, asynch processes like network calls, etc
ExpectedException better than nothing but still no bueno, it passes the test case when anything in the test throws the exception you want, even scaffolding/setup/etc. Truth.assertThrows has finer granularity
It’s not just about what you make - what if someone else modifies your code later and breaks it and there’s no test to catch it? When there are a lot of people touching a code base, unit testing is extremely important
It’s usually a code smell if it’s overly hard to write a unit test for something. I’ve always noticed there seems to be less emphasis with unit tests on iOS projects. Either way getting good at unit tests takes practice. Following the SOLID (Clean code acronym) development principles will make your life easier.
Manual testing does not catch regressions. Writing effective tests is a skill that you develop, just like you've improved your coding abilities over the years. It gets easier over time.
Sde2 with 250k tc who doesn’t believe in unit tests and automated testing 🙄 🤦🏻♂️ fuck this shit.
I've seen unit/integration tests prevent million dollar catastrophies, and I've seen the lack thereof result in them. Take a look at the book "working effectively with legacy code", which defines legacy code as code that is not covered by tests. It might hit home a little.
Thanks for the book reference, I will definitely check it out. Any other resources I can use to further appreciate the value of unit tests would be great as well.
Can you describe any examples of when unit tests have prevented catastrophies as you said?
2024 Tax
11h
1916
Biden’s new tax proposal is wild
Tech Industry
Yesterday
49379
Goog Employees Arrested
India
13h
1143
Lost respect for Modiji
Tech Industry
18h
2480
Go woke, go broke: Google fires 28 employees involved in pro-Hamas protest
2024 Presidential Election
3h
1067
Biden ruined America and tech! Tax plans are insane
Doesn't iOS and Android code have unit tests?
Yes, absolutely. I believe the testing tools and methodologies are more mature on web and backend development though.