Hacker News new | ask | show | jobs
by BeetleB 598 days ago
Mostly agree.

My first thought when I read this post was: Is his goal to test the code, or validate the features?

The first problem is he's providing the code, and asking for tests. If his code has a bug, the tests will enshrine those bugs. It's like me writing some code, and then giving it to a junior colleague, not providing any context, and saying "Hey, write some tests for this."

This is backwards. I'm not a TDD guy, but you should think of your test cases independent of your code.

3 comments

But in a system that exists without tests (this is the real world after all), the current functionality is already enshrined in the app.

Adding tests that capture the current state of things, so that when that bug is uncovered tests can easily be updated to the correct functionality to prove the bug prior to fixing it is a much better place to be than the status quo.

The horse may have bolted from the barn, but we can at least close the farm gate in the hopes of recapturing it eventually.

Right! AI is going to help you write passing tests - not BREAK your code, which is the whole point of writing tests.
Tests are not just for breaking your code. Writing passing tests is great for regression testing, which I think is the most important kind of unit testing.

If your goal is to break your code, try fuzzing. For some reason, it seems that the only people who do it are in the field of cybersecurity. Fuzzing can do more than find vulnerabilities.

> not providing any context

You can provide the context to an AI model though, you can share the source with it.