▲ | tmoertel 4 days ago | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
I think what you're missing is that "you write tests so that you know your code works" doesn't actually work for some important classes of "works," security and concurrency (the subject of this HN discussion) being two prominent ones. That's because testing only shows that your code works for the cases you test. And, when it comes to security and concurrency, identifying the cases that matter is a hard enough problem that if you can figure out how to do it more reliably, that's publishable research. Think about it: If you're writing code and don't realize that it can deadlock under certain conditions, how are you going to realize that you need to test for whether it deadlocks under those conditions? If you're writing code that interpolates one kind of string into another and don't realize that you may have created an XSS vulnerability, are you suddenly going to gain that insight when you're writing the tests? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
▲ | latchkey 4 days ago | parent [-] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
You run your code in production, you see it is deadlocking and you fix it. How do you fix it? You write a test the reproduces the deadlock, you fix the code and your test passes. Just like any other testing. I'm not arguing that you magically predict everything that's going to happen. But, without those tests and the culture of writing tests and writing your code to be testable, you're screwed when you do have bugs in production. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|