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

Filip Hric 13th May 2025 TO BE OR NOT TO BE (TECHNICAL) Hey Reader!There’s an ongoing debate in the QA world on whether it makes sense to get technical or not. I remember having a fairly heated debate on this last November at Agile Testing Days in Potsdam. My talk titled "Test like a developer, develop like a tester" argued that we should put the effort as testers to become experts in the software we test. And yes, that includes having a fair bit of developer knowledge. Jason Arbon called...

Filip Hric 23rd April 2025 AN APP CAN BE A HOME-COOKED MEAL He Reader,Today I’d love to share with you one of the best blogposts I’ve ever read. It warmed my heart and inspired me greatly. The blogpost is called "An app can be a home-cooked meal". Give it a read. It taps into something that’s really close to my heart - using your talents to make a world a better place - starting with your family. While you can be a world-renowned chef, it will always feel different when you cook a meal for...

Filip Hric 24th March 2025 Playwright in Production Hello Reader,I’ll be doing a live webinar with my friend Jonathan tomorrow. We’ll be talking about different use-cases of Playwright in production. Interestingly we’ll focus on use cases that are outside of testing, like web-scraping, monitoring and automation workflows. Make sure to register and join us! Register here Blogposts, discussions, events In Case You Missed It – Code (r)evolution Livestream Last week, Jonathan and I unpacked...