How SonarLint for IntelliJ decides if a file is a test

Sonarlint for IntelliJ displays the warning of using test libraries such as Assertions class in production code. However, the code uses the test Assertions is actually test file instead of production code. It looks like SonarLint for Eclipse and VSCode have the settings for specifying which file should be considered as tests. Intellij does not have the similar settings. Is there a way to address the problem?

  • Operating system: MacOs
  • SonarLint plugin version: 8.2.0.68615
  • Programming language you’re coding in: Java
  • Is connected mode used: No

Hi @Jing_Li,

We rely on project information to decide which files are tests and which are not. This information can be overridden in the Project StructureModules part.

If that’s a problem for you and you want to address it, you can vote for an existing idea or submit a new one, so your feedback can be taken under consideration!

Thank you for using SonarLint!