Hacker News new | ask | show | jobs
by dandellion 1192 days ago
In my case about 50% of the test code is just boilerplate, so I usually type the test name and generate the rest. Most of the time I have to rewrite the actual test logic (although very trivial tests are sometimes correct), but I probably keep more than 40% if we're talking tests specifically.
1 comments

> In my case about 50% of the test code is just boilerplate

Why not replace it with a function call?

A common occurrence is something like a pool of 10 actions where a bunch of tests each do 3 to 7 of them. This is very hard to abstract with a function call.
That makes the test harder to read. Tests should be dumb.
In the case I was referring to, mainly to keep the code consistent with what was already there and the PRs small, as the code base is primarily owned by a different team. It's also pretty innocuous short tests that read well as they are.
Some languages are just noisy.

Go, Java I’ve experienced are noisier than others.