You are viewing a single comment's thread.

view the rest of the comments →

2
1

[–] justletmevoat 2 points 1 point (+3|-2) ago 

They break stupidly when code changes, and people defend them saying "Oh, well, good unit tests don't do that", and then these good unit tests never exist, and you've got to stub or mock everything, so your tests don't test any fucking thing useful, and then the API for the DB library changes or you have to update versions and you have not only update your tests to that, but also the fucking stubs.

Fuck unit tests - out of all the different kinds of testing possible it is the most useless.

0
1

[–] kherrera 0 points 1 point (+1|-0) ago 

I agree with how time consuming and complicated it can be, but I disagree that it is useless.

If a unit test breaks and you know about it, then it did its job. Expectations have been changed and the error you see as a result of a failed test is a heads up. Depending on the type of project that is being developed, it is very useful in order to re-evaluate the changes that were made, or to update related processes. It's an excellent way to find regressions before they are pushed to production.

I personally find it tedious to write tests, but I appreciate the piece of mind I get even more after running the tests and getting back a clean result. Some would argue that a clean result doesn't really mean anything, but in practice it comes down to how well the tests were written.

0
1

[–] TheGuyWithFace 0 points 1 point (+1|-0) ago 

Also, I find unit tests very useful for learning about the system I'm working with when I'm first coming onto a project. It's still tedious, but not as much so because I'm learning about how everything fits together as I write my test. Once I'm done I feel a lot more confident about modifying other parts of the codebase and working on bigger tasks.

0
1

[–] taxation_is_slavery 0 points 1 point (+1|-0) ago  (edited ago)

If you're paid by the hour they are wonderful wastes of time. Though I prefer more interesting things, if you hate the company you're doing work for it's one option.

0
1

[–] boater 0 points 1 point (+1|-0) ago  (edited ago)

I think whether or not unit tests save you time depends on your development methodology.

They work well in conjunction with pure functional programming, where one might write a 10 line function, and then a 2 line test below it in the same file, where the test is just a boolean function equality test returning whether or not the primary function returned the expected return value when it was called with a handful of input parameters.

I would agree that writing unit tests for non-determinsitic input-output code or writing unit tests in a seperate file or folder than the code being tested can be a waste of time, but if you have your build system setup to automatically parse unit test signatures from your modules and automatically generate a custom binary to call them, they can be a convenient way to clarify an API and make it feel more stable during the process of writing it.

0
1

[–] TheGuyWithFace 0 points 1 point (+1|-0) ago  (edited ago)

"Oh, well, good unit tests don't do that", and then these good unit tests never exist

But they very much do exist. It takes a fair amount of forethought - you have to design your system ahead of time to be modular and think about these things as you go, but good, non-brittle unit tests absolutely exist. If you're having to mock everything every time you write a unit test, that's probably a sign your code could use some refactoring.

0
1

[–] sparkybear 0 points 1 point (+1|-0) ago 

I get the importance of some unit tests. But I don't think that they need to be done for everything. I don't agree with justletmevoat, but I also don't agree that we always need them. I think they are good for specific tasks that require either a lot of validation with a lot of moving parts, but I don't see them being useful for smaller things. Maybe because I haven't really done test-driven development, but the way I've seen them implemented in most cases seems like a waste of time.

0
0

[–] theonlylawislove ago 

It sounds as if you do not know how to unit test.

0
0

[–] justletmevoat ago 

I'm sick of having other people's unit tests break for shitty reasons.