JUnit Test - static quality code scan

Qonarqube version: 8.6 (build 39681)

Here is what I would like to achieve:
For a given project, to enable some rules for code source AND for my junit tests. For example, the rule java:S2208 Wildcard imports should not be used should be enabled whatever the type of code (source or tests). Some rules about complexity could be violated by JUnit tests code but not by source code.

Is it already possible to do it?

Workaround (that I’ve not tested):
I could include the junit tests as normal source code during the code scanning but then the same rules will be enabled for test and source code.


Welcome to the community!

This is indeed the most common approach.

I’d love to tell you there’s a secret switch to turn this on otherwise, but unfortunately there’s not.


Ok thanks for the info. Could it be a valid features to have in future release?
Something like be able to flag a rule to be executed on test source code too.

Believe me, we’re aware of the need. I’ve lobbied for this literally for years.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.