Comprehensive unit test coverage annotation
Most of us are used to using things like Cobertura for finding unit test code coverage.
Are there any set of annotations/framework that I can use开发者_开发技巧 to intelligently inform Cobertura to not test certain classes/methods/branches etc?
I am using maven so I can use the class level excludes to exclude classes however I am after finer level of control. For example
- Ignore this class (which is possible using excludes)
- Ignore just this method (because this one is going to be used only in test context, or is a trivial getter)
- Ignore a bunch of classes (because that is just the source code of a demo client)
- Have labels, for example if I run my code coverage with Integration profile then please check if I have covered this piece of code etc.
As far as i know cobertura instruments a complete class so ignoring a single method wouldn't work. The whole class can be ignored by just using excludes as you already mentioned. Furthermore to ignore a kind of a demo client this should be a separate module in Maven which simplyfies this just changing the configuration for coberatura-plugin.
Cobertura is open source, if you think this would be a great addition to the tool then contact the developers and get involved.
精彩评论