Reputation: 1868
As part of a custom testing framework for a NodeJS REST API, I'd like to automatically detect when my tests are no longer providing proper coverage by comparing all possible outcomes with what the test suite received.
What methods exist for doing this? We can assume that it's being used for a REST API with a list of entry functions (API endpoints) that need coverage analysis, and each entry function will end with a known 'exit function' that responds to the requester in a standard way.
Here's what I've found so far:
1: Basic solution (Currently implemented)
Pros: Very basic and easy to use; Doesn't change performance testing times
Cons: Highly prone to error with lots of manual checking; Doesn't flag any issues if there are 5 ways to 'FailDueToX' and you only test 1 of them. Very basic definition of 'coverage'
2: Static analysis
Pros: Automatic; Catches the different branches that may result in the same output code
Cons: Generating the parse tree is non trivial; Doesn't detect dead code that never gets run; test suite needs to be kept in sync
3: Profiling
I've done this in the past on Embedded Systems with GreenHills Code Coverage Tools
Pros: Semi Automatic; Gives more information about total coverage to a developer; Can see
Cons: Slows down the tests; Unable to do performance testing in parallel; Doesn't flag when a possible outcome is never made to happen.
What else is there, and what tools can help me with my Static Analysis and Profiling goals?
Upvotes: 1
Views: 740
Reputation: 9034
Combinatorial testing (different name suggestion would be appreciated)
Pros:: Semi automatic (having proper tools)
Cons:: Specification validation is tricky. I'm not aware of existing implementation.
Potentially helpful node modules:
Upvotes: 1