I was writing unit tests for half year or more at my work, hoping that I do good job. But the problem is I rarely see the benefit of them. So I don't understand, why it is good. Many of the test functions look like this - they test model functions.
protected function test_get_dogs_8_subtypes() {
$test_result = $this->Dogs_8_model->get_dogs_8_subtypes();
$expected_result = 'is_array';
$test_name = __FUNCTION__;
$this->unit->run($test_result, $expected_result, $test_name);
}
I run, if there is errors they fail so ok. But they will fail when I modify them. If I don't then they will never fail.
But when I modify some model function, I test the functionality of the sofware by hand anyway. So if there is error, functionality does not work and I fix the model function. So what extra thing this unit test for me does?
There were cases when unit testing made benefit. But that was like 5% of the cases probably. For example I was writing class which finds what is poker combination - flush, or straight or 2 pair, etc.
There those functions were depending heavily on each other. I don't remember exacluy, but checking if there is full house combination, I used to check if there is pair and trips combination. Do if I edit trips checking function then fullhouse checking function as well might be broken.
There the unit test helped a lot ,because when editing one function there was high probability of other functions braking and unit test quickly found out those.
But I don't see this with model functions.
Why is that? Maybe I don't get somehting? Maybe I should stop making those unit tests because they cost time, which means money, and giving no benefit.