• (nodebb)

    Fristly: code coverage should be in the 100-200% range! Secnodly: don't forget to cover the test code with tests!

  • (nodebb)

    If you measure code coverage, then you will get code coverage- and nothing else.

    Yes but no. It all depends on how your code coverage tool measures coverage. Some actually track which lines of application code get called, which (aside from questions of the time it takes and related things) is what you really want. Others measure nonsense like "we called a method of the class, therefore the class is 100% covered", which is very, very far from what you want.

    But even then, it's not a sufficient measure, because of a problem related to combinatoric enumeration. If you have a function where all its if()/else branches are covered, you might not have exercised all the permutations of branches, i.e. you have covered all the A paths and all the B paths, but you did it by covering AABA and BBAB, and there's a bug that only happens for BABB, so it ends up being found by a customer.

  • (nodebb)

    I should also point out that at $JOB we have some unit tests for libraries, and in one very important sub-library (a sort of object database), the unit test collection includes things like "I asked to create an empty group of objects, and the group that the library created was, indeed, empty" being the entirety of the test of object groups.

    At the same time, another module (a stateful IPS that verifies network packets) has an extensive test suite of about 9000 tests and nonetheless still doesn't achieve 100% coverage (by the "which lines did we hit" measure).

  • OverReacter (unregistered)

    At my $JOB we use Redux in our front-end applications to manage state. A number of our Redux action creators have tests of the form: dispatcher.dispatch(actionUnderTest); expect(dispatcher.dispatchedActions()).toInclude(actionUnderTest) i keep telling my peers that this basically equates to a expect(true).toEqual(true) test but the tests keep popping up.

  • (nodebb)

    Here at TDWTF we see a large number of WTFs that amount to "Here's this truly awful routine I found in our codebase that can't possibly work. Thank goodness it's not called form anywhere."

    The unit test in today's submission isn't totally useless. It identifies, and fails, if the routine in question is unused. Now all they need to do is write one such test for each member routine of each class. Might be interesting to create the moral equivalent for all property getters / setters as well.

Leave a comment on “Are You Mocking Me?”

Log In or post as a guest

Replying to comment #687512:

« Return to Article