Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

LLMs can’t write unit tests. They can’t even tell what you intend. If your code is already correct, you don’t need the unit test, if it’s not, the LLM can’t write the unit test. If you thing an LLM can write tests for you, you can be replaced by an LLM.


> If your code is already correct, you don’t need the unit test.

I don't know where you work where code is written once and is never changed again, but enjoy it while it lasts...


Worse is when a protocol or shared state condition is modified.

E.g. suddenly some fresh out of college know-it-all sent crap into your function that you weren't expecting. Then he went to management to blame you for writing such shitty code.

Thing is you wrote unit tests around that code and the shitty know-it-all deleted them rather than changing them when he modified the code

This is why management needs to understand code.


Recently on HN there was a thread debating the utility of having required code reviews for PRs.

I'm firmly on team "require a coworker to say okay before merging", and this is exactly why.


What? Is that a real example? Are you seriously working with people who delete your tests, misuse your code then complain about you to management?

Is your workplace filled with high school students? I’ve never seen anything so petty and immature in my professional career. I hope management told them to grow up.


> Is your workplace filled with high school students? I’ve never seen anything so petty and immature in my professional career.

I think the description I remember on glass door was that it was "high school all over again".


IMO, the main use case for LLMs in unit tests is through a code completion model like Copilot where you use it to save on some typing.

Of course, there are overzealous managers and their brown-nosing underlings who will say that the LLM can do everything from writing the code itself and the unit tests, end-to-end, but that is usually because they see more value in toeing the line and follow the narratives being pushed from the C-level.


> if your code is already correct, you don’t need the unit test

This is a hot take. I'm 100% not onboard with.


Correct. Unit tests are not only for the current version of the code, but also to prevent regressions in future versions of the same code.


I don't think the concept here is blindly taking the output of the LLM and calling it a day. One can test, the test.


I've had about 33% luck with unit tests coming out perfect. Usually the issues are small problems that are easily fixed though.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: