Testing Trivial Methods
Cover CLI 3.0 deliberately does not test trivial methods such as getters, setters, constructors and factory methods to avoid creating large quantities of noisy tests that do not contribute to overall coverage. There isn’t a benefit to be gained from testing these trivial methods directly as, for example, getters and setters simply access attributes so there is no actual logic to be tested. Similarly, constructors and factory methods also contain little or no logic. If Cover CLI 3.0 did test such methods directly, a minor coverage increase might be gained, but this “improvement” would be meaningless in terms of improving code quality. Ultimately these trivial methods will be covered when Cover generates tests for other methods that call these trivial methods. Diffblue recommends improving the percentage of coverage using the many options within the product, as shown in the CLI 3.0 Usage Manual.
JCover is different in that it is possible to test for trivial methods, using the command:
--no-factory-tests. The user has the flexibility of choosing whether or not to test these trivial methods.