"what is the point of the thing you're testing" tests are for change management, if that private function depends on other private function or some other code I need to know I broke it when I make changes somewhere else
I really don’t get why one shouldn’t write unittests for private functions. Ideally, a function encapsulates behavior and that can be tested. If I have a function that computes a formula, why wouldn’t I write a little test that asserts a few relevant values are mapped to the right result? If I for some reason decides to change the implementation, the tests can tell me quickly that it is this function in particular that has been at fault and not some higher-level public function, which is apparently fine to write tests for.
Tests aren't free, and so they need to have positive ROI. I'm arguing that tests for private functions have negative ROI, because that function is an implementation detail. If its functionality can't be tested "from the outside", i.e. from the public API, then it's unclear this function has any value. > If I for some reason decides to change the implementation Then you've probably deleted or bypassed that private function you wrote tests for, and the corresponding tests are now useless. This is the "not free" part. Does that make sense?
lol I mean, I'm using it for sideprojects. It's fun. I just don't have a good gui support with charts and graphs, but I guess I'll use raylib for that.
one of the most exciting talk I've ever watched.
I love this .. a great talk Atila. This "rant" is very encouraging to me,
"what is the point of the thing you're testing"
tests are for change management, if that private function depends on other private function or some other code I need to know I broke it when I make changes somewhere else
I really don’t get why one shouldn’t write unittests for private functions. Ideally, a function encapsulates behavior and that can be tested. If I have a function that computes a formula, why wouldn’t I write a little test that asserts a few relevant values are mapped to the right result? If I for some reason decides to change the implementation, the tests can tell me quickly that it is this function in particular that has been at fault and not some higher-level public function, which is apparently fine to write tests for.
Tests aren't free, and so they need to have positive ROI. I'm arguing that tests for private functions have negative ROI, because that function is an implementation detail. If its functionality can't be tested "from the outside", i.e. from the public API, then it's unclear this function has any value.
> If I for some reason decides to change the implementation
Then you've probably deleted or bypassed that private function you wrote tests for, and the corresponding tests are now useless. This is the "not free" part.
Does that make sense?
Was considering using D, but I guess this talk shows that it doesn't seem to have sane defaults. Sad
lol I mean, I'm using it for sideprojects. It's fun.
I just don't have a good gui support with charts and graphs, but I guess I'll use raylib for that.