Eclipse: files in /src/test/java not being scanned

Planning on using SonarLint to scan Test Automation Java files. Using Eclipse with SonarLint 4.1.

While playing with the tool, I noticed that the Java files under /src/test/java are not being scanned.

  • I am not connected to SonarQube
  • “Test file regular expressions” is blank
  • using Maven

Anyone?

thanks
Matt Wetzel

Hi,

Is the file not analyzed, or simply no issues are reported (you can check SonarLint console in verbose mode to see if something is triggered when saving a change to the file).

My guess is that you are using a recent version of Eclipse, that has built-in support for test source folders. And most rules of SonarJava are not applied to test sources.

Files are not being analyzed.
Using Eclipse version 2019-03

Any way to force SonarLint to look at /src/test/java?

Is there anything displayed in the SonarLint console (verbose mode enabled) when you open such file?

SonarLint analysis of project tutorial1 (19 files processed)…
File ‘src/test/java/net/serenity/tutorial/ui/SearchBox.java’ qualified as test by ‘JavaProjectConfiguratorExtension’
File ‘src/test/java/net/serenity/tutorial/model/Category.java’ qualified as test by ‘JavaProjectConfiguratorExtension’
File ‘src/test/java/net/serenity/tutorial/tasks/OpenTheApplication.java’ qualified as test by ‘JavaProjectConfiguratorExtension’
File ‘src/test/java/net/serenity/tutorial/steps/NavigatingUser.java’ qualified as test by ‘JavaProjectConfiguratorExtension’
File ‘src/test/java/net/serenity/tutorial/ui/CurrentPage.java’ qualified as test by ‘JavaProjectConfiguratorExtension’
File ‘src/test/java/net/serenity/tutorial/features/navigation/WhenBrowsingProductCategories.java’ qualified as test by ‘JavaProjectConfiguratorExtension’
File ‘src/test/java/net/serenity/tutorial/features/search/SearchByKeywordStory.java’ qualified as test by ‘JavaProjectConfiguratorExtension’
File ‘src/test/java/test.java’ qualified as test by ‘JavaProjectConfiguratorExtension’
File ‘src/test/java/net/serenity/tutorial/ui/CategoryNavigationBar.java’ qualified as test by ‘JavaProjectConfiguratorExtension’
File ‘src/test/java/net/serenity/tutorial/tasks/Search.java’ qualified as test by ‘JavaProjectConfiguratorExtension’
File ‘src/test/java/net/serenity/tutorial/ui/EbayHomePage.java’ qualified as test by ‘JavaProjectConfiguratorExtension’
File ‘src/test/java/net/serenity/tutorial/ui/GoogleSearchPage.java’ qualified as test by ‘JavaProjectConfiguratorExtension’
Standalone mode (project not bound)
Starting analysis with configuration:

Test files are scanned by SonarLint, but only a few rules of SonarJava are evaluated on test files:
https://rules.sonarsource.com/java/tag/tests

And the only way to increase analysis would be to move to /src/main/java, correct?

How does Java code under /src/test get classified as “tests” by Sonar. Is it based on the directory or a property that can be modified?

Please read the related part in the FAQ and tell me if this is not clear so that I can improve it: