Live data from Hacker News

The testing pyramid is an outdated economic model

wiremock.io

1–10 of 45 posts

Re: The testing pyramid is an outdated economic model

#2
"The pyramid is also an artifact of the era in which it was created. Computers were slower, testing and debugging tools were rudimentary, and developer infrastructure was bloated, cumbersome, and inefficient."

In addition to that, I think a major point is that the testing pyramid was conceived in a world where desktop GUI applications ruled. Testing a desktop GUI was incredibly expensive and automation extremely fragile. That is in my opinion where the pointy tip of the pyramid came from in the first place.

"But the majority of tests are of the entire service, via its API [..]"

I think this is where you get the best bang for your buck because your goal to keep your tests robust is well aligned with the goal to keep the API stable. This is not the case above and below, where the goal of robust tests is always at odds with change, quick adaption and rapid iteration.

Re: The testing pyramid is an outdated economic model

#4
I agree with the sentiment of the article: I've seen too many codebases where a lot of stuff is being tested via unit tests (sometimes even via heavy mocks). The main implication is that your code essentially becomes impossible to refactor, since you're basically testing how your internals are wired up and any change to your code structure immediately causes a big chunk of tests to fail even though on the outside everything still works.

Having said that, I think this mostly means that people find the term "unit" in "unit tests" ambiguous and they're just cargo culting it to mean "a single class" or whatever. That's the fundamental flaw that should be addressed. Basically that's what the article is saying as well, I guess, by implying that the API is the contract you should be testing, etc. But that is essentially just a long winded way of saying "The API is the unit".

Re: The testing pyramid is an outdated economic model

#7
Okay? This seems like a fluff blog post as the trophy concept was coined back in 2018 if I am correct. Coming from wiremock it makes sense given their product, but it is just marketing fluff.

Honestly, as long as the GUI tip remains as small as possible I am mostly fine with whatever shape it takes below there. For modern web applications with a lot of APIs it does make sense to use a trophy. For other applications without such a communication layer a more traditional pyramid does make more sense.

What a lot of people often seem to completely overlook in discussions like this is that the pyramid isn't a goal in itself. It is intended as a way to think about where you place your tests. More specifically place tests where they make sense, provide most value and are least fragile.

Which is why the GUI should be avoided for any test that are testing logic, hence being the smallest section on whatever shape you come up with. Everything else highly depends on what sort of infrastructure you are dealing with, the scope of your application, etc.

Re: The testing pyramid is an outdated economic model

#8
I would argue that this opinion has developed because the footprint of the average service has shrinked over the years.

If you're testing large, complex services that involve many different behaviours, you're still going to have a test pyramid. If you've implemented microservices, what you used to call an integration test has now become an e2e test in your new architecture. And you still don't want to have mostly that.

Re: The testing pyramid is an outdated economic model

#9
> The pyramid is also an artifact of the era in which it was created.

> Computers were slower, testing and debugging tools were rudimentary, and developer infrastructure was bloated, cumbersome, and inefficient."

What AMD giveth, Electron taketh away.

No matter how fast computers get, developers will figure out a way to use that extra compute to make the build and the test cycle slower again.

Of course it is all relative - it is hard to define what a "unit" test is when you are building on top of enormous abstractions to begin with.

No matter what you call the test, it should be fast. I feel productive when I can iterate on a piece of code with 2 second feedback time.

Re: The testing pyramid is an outdated economic model

#10

Another opinion on changing the testing pyramid https://antithesis.com/blog/testing_pyramid/

It's more of an advertisement rather an opinion.

They have a specific definition of "E2E" (apparently UI is not considered to be in it) and it works on docker platform only (so not for e.g. windows binaries). It can be good, but does not speak about the testing pyramid in general.

Post reply on HN