1395
Tests are code too (lemmy.world)
submitted 10 months ago by jroid8@lemmy.world to c/programmerhumor@lemmy.ml
you are viewing a single comment's thread
view the rest of the comments
[-] kevincox@lemmy.ml 6 points 10 months ago

Mutation testing is quite cool. Basically it analyzes you code and makes changes that should break something. For example if you have if (foo) { ... } it will remove the branch or make the branch run every time. It then runs your tests and sees if anything fails. If the tests don't fail then either you should add another test, or that code was truly dead and should be removed.

Of course this has lots of "false positives". For example you may be checking if an allocation succeeded and don't need to test if every possible allocation in your code fails, you trust that you can write if (!mem) abort() correctly.

[-] Lifter@discuss.tchncs.de 1 points 10 months ago

Right,too much coverage is also a bad thing. It leads to having to work on the silly tests every time you change som implementation detail.

Good tests let the insides of the unit change without breaking, as long as the behave the same to the outside world.

this post was submitted on 02 Nov 2023
1395 points (98.5% liked)

Programmer Humor

32054 readers
1602 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS