logoalt Hacker News

layer8yesterday at 4:36 PM10 repliesview on HN

I’d go further and say while testing is necessary, it is not sufficient. You have to understand the code and convince yourself that it is logically correct under all relevant circumstances, by reasoning over the code.

Testing only “proves” correctness for the specific state, environment, configuration, and inputs the code was tested with. In practice that only tests a tiny portion of possible circumstances, and omits all kinds of edge and non-edge cases.


Replies

crabmusketyesterday at 8:58 PM

> "proves"

I like using the word "demonstrates" in almost every case where people currently use the word "proves".

A test is a demonstration of the code working in a specific case. It is a piece of evidence, but not a general proof.

And these kinds of narrow ad-hoc proofs are fine! Usually adequate.

To rephrase the title of TFA, we must deliver code that is demonstrated to work.

Yodel0914today at 12:20 AM

Came to leave the same comment. It’s very possible to deliver code that’s proven to work, that is still shit.

aspbee555yesterday at 5:17 PM

I find myself not really trusting just tests, I really need to try the app/new function in multiple ways with the goal of breaking it. In that process I may not break it but I will notice something that might break, so I rewrite it better

show 2 replies
roelesyesterday at 7:58 PM

Since we can't really formally prove most code, I think property based testing such as with hypothesis[1] would make sense. I have not used it yet, but am about to for stuff that really needs to work.

[1] https://news.ycombinator.com/item?id=45818562

show 1 reply
array_key_firstyesterday at 8:59 PM

I agree - it's trivial to write 100% test coverage if your code isn't robust and resilient and just does "happy path" type stuff.

anthonypasqyesterday at 7:38 PM

if your tests cover the acceptance criteria as defined in the ticket, why is all htat other stuff necessary?

show 3 replies
shepherdjerredyesterday at 5:22 PM

A good type system helps with this quite a lot

show 1 reply
9rxyesterday at 9:16 PM

Testing is not perfect, but what else is there? Even formal proofs are just another expression of testing. With greater mathematical guarantees than other expressions, granted, but still testing all the same; prone to all the very same human problems testing is burdened with.

show 1 reply
user34283yesterday at 5:13 PM

I'd go further and say vibe coding it up, testing the green case, and deploying it straight into the testing environment is good enough.

The rest we can figure out during testing, or maybe you even have users willing to beta-test for you.

This way, while you're still on the understanding part and reasoning over the code, your competitor already shipped ten features, most of them working.

Ok, that was a provocative scenario. Still, nowadays I am not sure you even have to understand the code anymore. Maybe having a reasonable belief that it does work will be sufficient in some circumstances.

show 2 replies
simianwordsyesterday at 5:47 PM

I would like to challenge this claim. I think LLMs are maybe accurate enough that we don't need to check every line and remember everything. High level design is enough.

show 3 replies