Live data from Hacker News

Improving end-to-end test reliability

frantic.im

21–24 of 24 posts

Re: Improving end-to-end test reliability

#21

I love learnings on automated testing. From the perspective of someone who isn't used to TDD or even just building many tests, maintaining E2E tests often seems extremely cumbersome. I wonder if I'm just missing out on the best practices, or if the tooling simply hasn't evolved enough yet.

It's about tradeoffs. On one end you have precision, speed, reliability, diagnosability. At the other end you have "realness".

Unit tests fall on the far left, workload tests/E2E tests/testing-in-production fall on the far right.

It turns out that there's no 'wrong' level, there's just different tradeoffs. I've worked at a lot of companies that embraced the realness of E2E tests, but then suffered from the maintenance/performance/diagnosability/instability of those tests. I have colleagues who worked at places that avoided E2E at all costs, and suffered because they would have a green test run, but user scenarios that a simple E2E test would have caught, were completely broken.

IMO there is a lot that can be done to improve E2E testing at most companies, but they definitely have the capacity to add value to your release/testing pipeline.

Re: Improving end-to-end test reliability

#22
post #20

Earlier quoted context omitted.

That stretches the idea of a refactor, though. If a refactor changes the external behavior it's not really a refactor, which is a structural change. Unit tests when applied at an API level (which may be a very small unit or up to the level of a library, but that also stretches the definition of "unit test" depending on the size of the library) are there to ensure that changes to the internals don't impact the behavio…

Units by definition are not external behavior. sometimes they change external behavior, but there are a lot of changes that make code cleaner without changing external behavior. All too often I've discovered after a few years that I really need to split some unit into two.

To clarify, the unit's own behavior is indeed not external to itself. But the way it behaves from the perspective of a user of the unit is external behavior. Changing the behavior, from that perspective, of a unit will necessarily invalidate its tests (some at least) and is not a refactor. That was my point, if you are changing an API you are not refactoring, you are changing its external behavior.

But this isn't just a problem with unit tests, it's a problem with all tests. And really, it's not a problem. It's the cost of doing business. Anything in flux (where that change changes its behavior) will force you to change anything that depends on it, whether it's a test or a user/client. If you aren't willing to discard the tests then the tests "freeze" the system in place, regardless of their level or kind (unit, integration, end to end).

Re: Improving end-to-end test reliability

#23
A really hard problem that often arises when doing E2E tests, is creating and managing test data.

If you have one or more integrations to external systems, where you cannot control your test data, it becomes much harder to write stable E2E tests.

Some don't have test environments, some have too few. Most don't allow you to setup data easily either way.

You can, of course, mock the external systems, but if they play a large enough part, your tests start looking more like integration tests again, but with the added overhead of something like browser automation.

It's a hard balance to strike.

Re: Improving end-to-end test reliability

#24
I wish there were tools for small teams to achieve this level of sophistication. It seems like only massive corporations can do testing really well, because they can afford to assign multiple engineers to build and maintain their bespoke test systems.

I'm a solopreneur building an app with Flutter. Flutter's testing support is mostly broken and or unwritten. It's very frustrating.

Post reply on HN