logoalt Hacker News

A Better Vocabulary for Testing

132 points • by alpaylan • last Saturday at 10:15 PM • 31 comments • view on HN

Comments

ozim • yesterday at 4:29 PM

I would like "non-functional testing" to be called "cross-functional testing".

➕ show 1 reply
Blowoffvalve • yesterday at 5:51 PM

I loved this article. I find that the most important part of engineering projects is defining a shared vocabulary for discussing and aligning with other parties.

The vocabulary proposed that clear delineates across the various concerns you're testing against is particularly helpful.

jph • yesterday at 8:10 PM

There's low-hanging fruit IMHO by testing using semantic naming vocabulary with semantic error vocabulary.

Example macro: assert_approx_eq_with_relative_error!(a, b, err). It's a semantic name that explains more about what it does, and the macro also provides a test failure message that guides the developer, or an AI, toward fixes and documentation.

I wrote the Rust crate Assertables to help with this. See https://crates.io/crates/assertables.

What I learned is writing semantic testing can help many more kinds of higher-value testing. As a specific example described by the article, I use enumeration testing for proving the UK National Health Service Number validator in Rust is accurate i.e. the test literally checks every number, then I can write tests such as assert_valid_nhs_number("111 111 1111").

FabCH • yesterday at 6:02 PM

I find that the biggest problem with all these classifications is that at the end of the day, developers will write whatever works for them in the moment, and not care if it fits your theoretical box.

I did a paper on it once, to see what tests devs actually write: https://ieeexplore.ieee.org/document/11081450

➕ show 3 replies
jruohonen • yesterday at 3:45 PM

I think the alleged dictum between functional and non-functional is the biggest conceptual, theoretical, or even philosophical issue.

➕ show 3 replies
lucamark • yesterday at 9:15 PM

From a practical standpoint, I struggle to see the benefits of this 5-axis taxonomy buys us over the classic 2D model.

What: Functional (business logic) vs. non-functional (latency, resilience and robustness).

Level: Unit, integration, or system.

Yes the boundaries between unit and integration are not always well-defined. But strong static typing already eliminates whole classes of invalid inputs at compile time without needing runtime contracts and simplifies the unit-integration boundary.

Where I do see real value here is in test design to create more robust and resilient tests.

➕ show 1 reply
jerf • yesterday at 5:38 PM

I think the problem with testing vocabulary is that the field is just too continuous. We have all sorts of situations in the world where there is no sharp line, yet we have terminology for various chunks of the possibility space even so because there are still some sort of clump in the space that we can identify. For example, there isn't a true sharp line between any of the primary colors, but we do not generally have a problem labelling things as "red" or "green" or whatever even so. There is a certain personality type frequently encountered online that this bothers no end, who can't really deal with the idea of words that have fuzzy boundaries around them and struggle with the concept of a "fuzzy line", but most of us get on even so.

However, when there is no natural clumping, there isn't even a place to put the fuzzy boundary necessarily. I think a lot of testing has this problem. I've disliked "unit" versus "integration" terminology for at least a decade now, because to me there's just a continuum. Yes, obviously, tests can test more or less of the code base at a time, and can draw in fewer or more dependencies in the process, and arguably there is an important distinction between 0 other dependencies included and 1, but beyond that I've thought for a long time there aren't any other distinctions worth putting a label on.

There is value to tests that mock out all the other dependencies. There is value to writing stubs. There is value to bringing up those dependencies and mocking or stubbing out their dependencies. There is value to having a full staging environment and running acceptance tests by hand, and that staging environment itself can have any number of mocks or stubs in it itself. And there is no rule that says you rigidly must make this decision based on the exact number of dependencies away something is from your code, to the extent that that is even a well-defined concept, nor are "mock" and "stub" themselves some sort of bright shining line as one can mix and match them freely, nor is that the complete list of all possibilities. The result is a fairly smooth continuum of possible tests. In my opinion, any attempt to put labels on very particular bits of it raises the risk of overprivileging certain parts of the space just because they get a name and creating the streetlight effect on the named bits and causing the others to be missed.

Even "performance testing" versus "correctness testing" gets awfully fuzzy; again, there is arguably some value in saying this test has performance concerns and this other test is just related to correctness, but even "performance testing" still has to worry about a lot of other things too and I don't find it anywhere near a binary distinction. Anyone who has spent any time with performance testing has certainly learned the risk of worrying about "performance" without also worrying about all the other things we test for at the same time, or to put it another way, I can make my performance testing look really good if I let the code it is testing be incorrect.

It is unreasonable to expect a universal nomenclature catalog of such a smooth space. We can't even as a species completely agree on color delineations in the spectrum, which is a simpler problem in most ways.

➕ show 1 reply
crdrost • yesterday at 10:48 PM

> You can also use enumeration, which theoretically is complete (if you have infinite time and compute) [...] it should be possible to have a complete ordering of a type, which gives you the enumeration (some very clever PL person is going to pull out an example that makes me wrong here, please do so I can add a small note on it, or better write the note for me and I'll just insert it here).

There's no note to write; by referencing infinity you are theoretically correct. There is a practical problem with the argument when we don't invoke infinity but that's a separate issue.

Just to be clear there are multiple sizes of infinity and you are claiming that the size of the data types that we use in computation is the smallest of these, the "countable" infinity (the same infinity as the counting numbers 1, 2, 3, ... and the fractions 0/1, 1/1, 1/2, 2/1, ...).

However, one countably infinite set is the set of all bytestrings: the first is the zero-length one, the second is the length-1 bytestring containing a null byte, the third is the length-1 bytestring containing 0x1, [...] the 257'th one is the length-1 bytestring containing 0xFF, the 258th one is the length-2 bytestring containing 0x00 0x00, and so on.

All realizable data structures in your computer program are realizable because there's a chunk of computer code that realizes them; compiling them (or bundling them with an interpreter, if they're in an interpreted language) converts those numbers to a bytestring, so there's a surjection from the infinity of bytestrings to the realizable data structures. All that needs to be proven is that there's an infinity of realizable data structures, which honestly depends on your programming language and computation model -- technically a JavaScript string needs to be shorter than 2⁵³ - 1 UTF-16 code-points, so it's not a strictly infinite structure, and if your pointers have 64-bit addresses then your memory model is imposing a finite size on pointer-constructed data structures too: but the point is that if you remove all of these constraints and graduate to an infinite memory model with infinite numbers of pointers, as long as you don't introduce uncountable infinities on the way, then you get a bijection by the Cantor-Bernstein theorem and the number of data structures is a countable infinity.

Edit: forgot to complete the thought; on the other hand there is a practical problem because the number of bytes you have to generate to cover all bytestrings of length n scales as n × 256ⁿ which for all bytestrings of length 6 is already 1.5 petabytes, even if you reduce it down to printable ASCII strings that only gets you about 20% more reachable length, so length-7 printable ASCII is 0.5 petabytes when enumerated. Or for comparison with an hour of Markov searching on my RTX 4070 I can get hashcat to break an 8-character pronounceable password, as the limit of what I can test within the bounds of a testing setup with a highly optimized character-generation pipeline.

Meanwhile the bugs that you run into are in weird claims in a 400-byte JWT token or numbers that go over your precision limits when decoded from a 1KB JSON payload or a 10KB config file with duplicated keys that parses one way from this pipeline and a different way from some other pipeline, or a 10MB file blowing past some internal buffering limit and switching you from synchronous processing to streaming processing. 7 bytes ain't gonna cut it.

➕ show 1 reply
gzell • yesterday at 4:28 PM

Always enjoyable for us aged s/w engineers to see the new generations relearn the fundamentals.

➕ show 1 reply
g-b-r • yesterday at 4:41 PM

I recall finding different definitions in every book about testing I read.

I think most of the confusion came from people suddenly deciding that a unit test can't test less than a whole object, in OOP.

➕ show 1 reply
gfalcao • yesterday at 5:17 PM

great infographic

xiaoliangliang • today at 3:22 AM

[flagged]

nonacosa • yesterday at 9:25 PM

[flagged]

enoch_hou • yesterday at 5:14 PM

[dead]

sfeizi • yesterday at 5:29 PM

does vocabulary matter anymore as coding agents can make interpretations?

➕ show 3 replies