How to create toast in SwiftUI

Sometimes you just want to show the user that some process is loading, or completed without the need to “Dismiss” the alert. Using the built-in alert when a user favorited a song or add it to a…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




The Fallacy of Feature Tests

You guys probably know about unit tests. A small, atomic test that covers the smallest unit of logic you can manage.

I bet you also know about integration tests, where you test your system across multiple modules or classes even using database interactions.

But do you know about feature tests?

Probably not, since this is something that we came up with in-house, so there’s no relation to any industry practice of which I’m aware.

I’d like to take you guys through the history of this idea and its inevitable demise in the hopes that even one person might not fall into the trap that we did.

So, why don’t we just use unit tests and integration tests? It’s industry standard and it’s a proven approach, so what’s the deal with this other type of test?

Well, we were in a situation where we were building things very, very quickly. We’re talking build-an-entire-iOS-and-Android-mobile-app-with-multiple-user-bases-and-advanced-functionality-in-a-month-and-launch-it quickly.

And in the midst of slinging features left and right, we noticed that in a few places we were building utility, service, or repository classes that were only used by a single other class.

We would then write some unit tests for that utility. Then we’d write unit tests for the client of that utility, and some of the tests would be the same assertions. The utility class would be retested by the client. (we don’t use mocks much on this team, but that’s a whole other post…)

“So,” I think, “we’re writing the same tests twice! Let’s just write them once. Write once, use multiple places, right? That’s smort. Reeeal smort.”

So I bet you can guess what we did next. We deleted the utility class tests, and added all of those assertions and test cases to the client of the utility.

We still got 100% test coverage, and now we were only writing the tests once, running them once, and covering integration and unit testing in a single test.

Efficient, no?

Remember when I had the brilliant idea to reuse code to be more efficient? Well, I actually do that quite a lot.

Add a comment

Related posts:

Offering Incentives

Bringing on a new associate isn’t about just giving someone a job. It’s about the team. It’s about the centre itself.

The Importance of Friendships

Over this past weekend, I had a thought lingering on my mind for the past couple of days. It is the importance of friendship. For me, it is easy to forget how vital those long-term relationships…

If you Enjoy Thrillers

Foster is one determined woman. As an immigrant from Slovakia who came to Britain as a nanny, she knows from personal experience that most Britains think immigrants are disposable. That’s why she is…