TestCases should contain tests (squid:S2187) also checking files that are not in test directory.

80 views
Skip to first unread message

Matthias Kolley

unread,
Aug 22, 2017, 1:18:11 AM8/22/17
to SonarLint
As squid:S2187 description states:


This rule raises an issue when files in the test directory have "Test" in the name or implement TestCase but don't contain any tests.


But this rule also raises an issue when I have a XyzTest class in "src/main/java"

I am using:
Eclipse for RCP and RAP Developers

Version: Neon.3 Release (4.6.3)
Build id: 20170314-1500

SonarLint 3.2.0

The project this file is in is bound to a sonarqube version 6.3.1.2139

But it doesn't matter wether it is connected or not. it is always showing this issue.


duarte.meneses

unread,
Aug 24, 2017, 11:41:44 AM8/24/17
to SonarLint
Hi,

SonarLint might be considering that file to be part of the test sources.
Unfortunately in Eclipse, SonarLint can't figure out if a file is a test or not, so a regular expression is used to decide.

If you open the SonarLint logs with verbose enabled, you can check if that's the case. 
First in the list of input files:
  inputFiles: [
    /xxx/xxx.java [test]
  ]

And then during the execution of the SonarJava:
Java Main Files AST scan
0 source files to be analyzed
Java Main Files AST scan (done) | time=0ms
Java Test Files AST scan
1 source files to be analyzed


If this is the problem, you can change the regex in Preferences -> SonarLint.
Reply all
Reply to author
Forward
0 new messages