Abstractions in Test Automation: Friend or Foe?


Filip Hric

14th January 2025

Abstractions in Test Automation: Friend or Foe?

Hello Reader,
I’ve been recently doing some thinking about abstractions in tests. The promise is that they simplify test code, but reality seems to suggest the opposite.

Here’s the dilemma: The bigger the codebase is, the more it feels like it makes sense to not repeat yourself. While abstractions prevent repetition, they often come with unintended consequences—changing one abstraction can ripple through an entire code base. This is a common problem in app development (I edit stuff here, the app breaks there), which is the reason we write tests in the first place - but it seems that when it comes to writing test code, we deal with same problems..

I brought this discussion to my social networks, and some some of you shared valuable perspectives. To sum up the arguments I found most compelling:

  • Repetition Isn’t Always Bad: Tests benefit from clarity over cleverness. Small, targeted utility functions often outperform sprawling abstractions.
  • Focus on the Essentials: Instead of obsessing over eliminating repetition, channel your energy into crafting meaningful assertions and a strong test strategy.
  • Ask This Question: Can I delete this code easily? If not, your abstraction might be doing more harm than good.

My takeaway is that test code should be simple and descriptive, not clever. Next time you’re tempted to abstract, ask yourself: Is this solving a problem, or creating one?

What’s your approach to balancing abstraction and clarity? Hit reply—I’d love to hear your thoughts!


Blogposts, discussions, events

k6.io workshop 🇨🇿

My friend Dan is launching a web performance workshop. You do not want to miss it. You’ll learn about modern approaches to Performance Testing and Performance Observability. The workshop is in Czech language

Read more →

v0.dev

Hardest part in building my course was manually coding test apps for examples. v0.dev has been a godsend. Honestly can't believe how much time I've saved.

Watch the video →

99 Cypress tips

I'm still preparing a special course for you! It takes a bit more than I expected, but I’m truly excited for it! It will feature bite-sized advice to help you master configuration, API testing, advanced networking, DOM manipulation, performance, and debugging in Cypress. Stay tuned!

Watch the update →


Test automation tip

When creating custom functions and helpers for your Cypress tests, you can create custom log groups. These will couple all the commands inside the function in a visual group in Cypress timeline. This is quite helpful when debugging your tests.

 1  const createCard = (cardName) => {
 2    cy.then(() => {
 3      const log = Cypress.log({
 4        name: "createCard",
 5        message: cardName,
 6        groupStart: true,
 7      });
 8  
 9      cy.contains('Add another card')
10        .click()
11  
12      cy.get('[data-testid="new-card-input"]')
13        .type(`${cardName}{enter}`)
14  
15      cy.then( () => {
16        log.endGroup()
17      })
18    })
19  }

The resulting code will appear in the Cypress timeline like this:


Meme of the week


Keep learning and growing 💪

Filip Hric

Teaching testers about development, and developers about testing

filip@filiphric.sk, Senec, Slovakia 90301
Unsubscribe · Preferences

Filip Hric

Sign up for weekly tips on testing, development, and everything related. Unsubscribe anytime you feel like you had enough 😊

Read more from Filip Hric

Hey Reader,, Theo asked a question this week that’s been sitting in the back of every developer’s head: how much better do the models have to get before you stop reading the code? It’s been going on for days, but I honeslty love it. We are talking about verification and quality! Although the initial question might not be the right one. Reading was never the goal, it’s one tactic for earning the right to ship something. If reading is the sharpest tool you’ve got, read. If you have something...

Hey Reader,, A few years ago Cursor was a nicer place to type code. This week it announced Origin, its own Git competitor built for agent workloads, and got acquired by SpaceX for sixty billion dollars. Somewhere in between, it stopped being an editor and started becoming the whole stack — the place you write, review, merge, and increasingly test your software. I come from QA, so my first instinct isn’t excitement, it’s a question: when one tool owns every step of the loop, who’s the...

“Too dangerous to release” has become its own genre of AI announcement. Project Glasswing is the latest entry: not quite a product launch, but a claim about a threshold, dressed up with enough corporate coalition to signal this one is serious. Anthropic says their new security-focused model, Claude Mythos Preview, can find software vulnerabilities better than all but the most skilled human experts. George Hotz challenged the “too dangerous to release” narrative by pointing at the obvious:...