Live data from Hacker News

Save the code or save the tests? (2020)

qntm.org

1–10 of 33 posts

Re: Save the code or save the tests? (2020)

#2
Saving only the tests is completely nonsensical. Even with 100% code coverage, tests will only cover a tiny fraction of the programs behavior. The original program of course fully describes its behavior. If you are lucky you might even have a description in the comments why some part of this behavior was chosen.

Re: Save the code or save the tests? (2020)

#3
> Doesn't matter how good the tests are, by the time you've "reconstructed the code" from tests you're out of business. Running code with no tests makes money. Tests with no running code don't.

^^ comment from someone named hobbs

Exactly. Users can tolerate an app that's kinda broken in some ways, but tests don't make money. In fact tests can often cost money anyway if they're not testing what's really important. No matter what, there are going to be parts of your code that simply cannot be described by the tests that were written.

Re: Save the code or save the tests? (2020)

#5
If I were to lose all the code for my Elite: Dangerous 3rd party application, I'd not be losing just the code - I'd be losing all the UI stuff.

Even IF I ever wrote unit tests for it - which I don't do and have never done for anything - those unit tests wouldn't have anything in them from which I could reconstruct the UI.

No. You save the code and the surrounding UI and the UI glue code.

Re: Save the code or save the tests? (2020)

#9
I have worked in the airline industry with scheduling algorithms. We had a very comprehensive test suite, but reconstructing the algorithms from that would take a decade. That surely only works for toy code bases. No one saves the tests.

Re: Save the code or save the tests? (2020)

#10
> More recently, out of curiosity, I pitched the same question as a poll on Twitter. On Twitter, roughly 80% of respondents said that they would save the application code and 20% said they would save the tests.

Surprise, common sense.

Saving the tests is like needing to know the answer to the Ultimate Question of Life, the Universe, and Everything (which is 42) and discarding the question.

Post reply on HN