Most active commenters
  • s_ting765(5)
  • yakshaving_jgt(4)

←back to thread

Delete tests

(andre.arko.net)
125 points mooreds | 11 comments | | HN request time: 1.786s | source | bottom
Show context
recursivedoubts ◴[] No.45071410[source]
One of the most important things you can do is move your tests up the abstraction layers and away from unit tests. For lack of a better term, to move to integration tests. End-to-end tests are often too far from the system to easily understand what's wrong when they break, and can overwhelm a development org. Integration tests (or whatever you want to call them) are often the sweet spot: not tied to a particular implementation, able to survive fairly significant system changes, but also easy enough to debug when they break.

https://grugbrain.dev/#grug-on-testing

replies(11): >>45071535 #>>45071726 #>>45071751 #>>45071944 #>>45072117 #>>45072123 #>>45072158 #>>45072321 #>>45072494 #>>45074365 #>>45080184 #
RHSeeger ◴[] No.45071726[source]
Integration tests and Unit tests are different tools; and each has their place and purpose. Using one "instead" of the other is a mistake.
replies(8): >>45072079 #>>45072176 #>>45072722 #>>45072873 #>>45073135 #>>45074394 #>>45080460 #>>45093392 #
1. s_ting765 ◴[] No.45072722[source]
Integration tests make unit tests absolutely redundant.
replies(2): >>45073253 #>>45073256 #
2. integralid ◴[] No.45073253[source]
Integration tests are as old as unit tests, and both predate their names. When exactly were unit tests made redundant? I don't see the point of your quip without a trace of actual argument.

I feel like I don't write enough tests, and when I do they're usually integration tests, but some things - algorithms, complex but pure functions, data structures - absolutely deserve their unit tests that can't be reasonably replaced by integration/e2e tests.

replies(1): >>45073374 #
3. yakshaving_jgt ◴[] No.45073256[source]
No they don’t.

If you’re, for example, writing a web application, and you have an endpoint which parses some data from the request and then responds with the result of that computation, why the hell would you test the fine-grained behaviour of your parser by emulating HTTP requests against your server?

Testing the parsing function in isolation is orders of magnitude cheaper.

replies(1): >>45073388 #
4. s_ting765 ◴[] No.45073374[source]
Here's the argument backing up my claim.

Unit tests don't matter when you have other types of testing like functional or integration testing that will tell you whether your code has the intended behavior and effect when run.

In the above statement unit tests is also considered as code.

That's where the redundancy comes from.

replies(1): >>45073615 #
5. s_ting765 ◴[] No.45073388[source]
Cheaper to run tests does not mean better. And your example does not test for real world behavior therefore the test is lower quality by definition.
replies(1): >>45078156 #
6. skydhash ◴[] No.45073615{3}[source]
Unit tests do matter, especially when the logic is somewhat complex or very defined (splitting money, parsing some message). So unless the specs change, you rarely have to modify the tests. So it helps more in a technical sense, catching developer mistakes. Just like qa tests on some small part of the car can spot defect early on.

Integrated tests is more about ensuring what matters to Product. A car that refuses to start is worthless for most cases. But the engine light and a window that can’t open is not usually a dealbreaker.

Unit tests can help pinpoint an issue or ensure that a specs is implemented. But that’s mostly relevant to the developer world. So for a proper DX, add unit tests to help pinpoint bugs faster, especially with code that doesn’t change as much and where knowledge can be lost.

7. yakshaving_jgt ◴[] No.45078156{3}[source]
All else being equal, cheaper is absolutely better.

How does my example not test real world behaviour? I mean, I didn’t even provide any code here so what exactly are you imagining?

replies(1): >>45080732 #
8. s_ting765 ◴[] No.45080732{4}[source]
Your example scenario avoided doing an end to end test for the data processing involving the parser instead opting for a unit test just for the parser.

We have developer sandboxes for this purpose so you don't have to guess the structure of the data you will receive from the actual server.

Also if all else was equal between multiple types of test, there wouldn't be need for comparison ala cheaper.

replies(1): >>45080872 #
9. yakshaving_jgt ◴[] No.45080872{5}[source]
How do you know that? How do you know that I wouldn't write an integrated test which verifies that my parser is correctly integrated with my system?

The point is, there is typically more than one path through the logic of a parser. The cheapest way to test these paths is in isolation. If there are five paths you care about, you could write six integrated tests — one for each of the five paths you care about, and one to verify that your parser is correctly integrated with your system, or of course you could write five isolated tests (which are cheaper to write and cheaper to execute) and one integrated test.

So, five cheap tests and one more expensive test, or six more expensive tests.

> Also if all else was equal between multiple types of test, there wouldn't be need for comparison ala cheaper.

…What? I'm sorry, this is near enough unintelligible.

replies(1): >>45081165 #
10. s_ting765 ◴[] No.45081165{6}[source]
> How do you know that? How do you know that I wouldn't write an integrated test which verifies that my parser is correctly integrated with my system?

You already said so in your first argument: Unit tests are cheaper and better(than integrated tests I presume).

Am simply following your behavior pattern here.

> The point is, there is typically more than one path through the logic of a parser. The cheapest way to test these paths is in isolation. If there are five paths you care about, you could write six integrated tests — one for each of the five paths you care about, and one to verify that your parser is correctly integrated with your system, or of course you could write five isolated tests (which are cheaper to write and cheaper to execute) and one integrated test.

This is nonsense. A standard parser takes one input and does processing of this data to give an expected output. An integration test checks the parser does this one objective correctly. You have boiled down the 5 unit tests that don't test for anything *real into 1 integrated test that objectively gives better test data.

*code is not real until it does some business logic!

> Also if all else was equal between multiple types of test, there wouldn't be need for comparison ala cheaper.

> …What? I'm sorry, this is near enough unintelligible.

Maybe try to froth less when reading my comments, your brain might have some capacity left to understand comparitive adjectives.

replies(1): >>45081378 #
11. yakshaving_jgt ◴[] No.45081378{7}[source]
> This is nonsense. A standard parser takes one input and does processing of this data to give an expected output.

This appears to be the root of your confusion.

Here's a good example of a parser: https://entropicthoughts.com/parser-combinators-parsing-for-...

There are at least 16 paths through this function.

Not one.

16.