Test User Feature, Not code

Technical,Testing

title: Test User Feature, Not code created_at: 2025-12-13T14:52:16.823Z updated_at: 2025-12-13T14:52:16.823Z tldr: Only the guy who worte the code like it, true story! is_published: true star: false category: Technical,Testing share_type: share

Ok, a very controversial opinion - you can skip unit tests, integrations, and everything else in between. The only tests that matter are the ones that mimic the user behaviors. Everything else is invisible to customers and engineers. From a code perspective, the tests become a liability for maintenance. Honestly, we have caught more bugs in our Playwright tests (this is one of the tools, you might have an RPA) than in our unit tests.

Writing a test to test a feature

Start with a scene, like a script in a drama.

Scene

- There is a bad guy
 - And (Action)
  - Bad Guy kidnaps a princess
 - Then (Event)
  - A hero is born.
 - Does (Action)
  - Fights and defeats the Bad Guy.
 - End (Result)
  - Princess Falls in love with the hero

Princess Falls in love with the hero is the desired result. This is the only acceptable result. Now, let's do that for a feature. Say a login screen.

Login Scene

- (Event) User visits the login page
- (Action) Enters Email in the "Email" Input Box
- (Then - Event) A loading Indicator with a success message "Sent a secret code!"
- (Action) Enters the "Secret code" in the "Secret Code" Input Box
- (Result) Success message

The same script can be used to replicate a failure scenario.

Login Scene

- (Event) User visits the login page
- (Action) Enters Email in the "Email" Input Box
- (Then) A loading Indicator with a failure message "Invalid Email."
- (Result) Suspend - No further action

or show a unique case where the user doesn’t exist

Login Scene

- (Event) User visits the login page
- (And) Enters Email in the "Email" Input Box
- (Then - Event) A loading Indicator with a Note message "Not Registered."
- (Result) A button for the signup page appears

Writing just these cases has tested the validation of email; your servers are working. And 99% of the users should be going through the same cases. If there is a failure, then the new bug is a requirement that has not been handled, like the user tried to login after 4 years, but the account is suspended.

At this point, you might be telling me that - our product team is strict, they want to test if the color of the header changed as well, “we do not want the users to see wrong colors in production”. For this, my answer is “Who cares?” Well, how many times do the colors change (Taking color as an example)? This will eventually be caught while developing - testing - PR Review, or product testing. Or at least someone internally will point this out. Even so, if it sees the customers, they can still use the feature - get the work done.

I bet we can break down every product requirement into these small snippet of feature and eveny only if these are tested out, I can safely assure you you are 90% good.


PS. Writing the script for drama got me other results as well. It was in the draft, keeping it just for fun!

- Hero sees the bad guy and shits in his pants /*fart noises in the background*/
- Hero sees the bad guy and falls in love
- Bad guy goes Nixon on the hero
- Hero sees the princess and says, "Not worth it," and turns around
- Princess turns out to be the hero\'s half sister, and the bad guy is actually their dad /*cc @Apurva*/