Re: [sonar-dev] How can I registermy custom checks for unit tests with java plugin 3.2 ?
Hi Nicolas, thanks for your reply. I must admit that this is not a good news :-(
Here is a (small) subset of the checks I have already developed / or plan to develop :
- IgnoredTestWithValidDocumentationCheck (INFO, is triggered if message matches a given regexp, in our case it means that a JIRA ticket is provided)
- IgnoredTestWithNoDocumentationCheck (BLOCKER, @Ignore or @Ignore("") should never be used)
- IgnoredTestWithBadDocumentationCheck (BLOCKER, is triggered if message does not match a given regexp, in our case it means that no JIRA ticket is provided, which in turn means that we are pretty sure that nobody will fix the test later)
- MissingAssertionCheck (MAJOR, includes a large set of assertion methods such as junit assertions but also assertj assertions, mockito verify, powermockito, etc.)
- PoorlyNamedTestMethodCheck (CRITICAL, triggered if a test method name does not match a regexp. we prefer to have well self documented test method names rather than documented assertions)
- TooManyAssertionsCheck (MAJOR, soft assertions should be used instead of multiple blocking assertions which lead to useless unit tests)
- MissingTestCategoryCheck (CRITICAL, we only run tests correctly categorized, no category means that the test won't be run)
- NoKnownTestCategoryCheck (CRITICAL, we only run tests correctly categorized, no known category means that the test will never be run)
- ConflictingTestCategoriesCheck (MINOR, conflicting categories means that the test will be run multiple times which is a waste of time)
If some of these checks can be useful to the community I would be glad to write and donate them / ask my company to donate those which are already developed.