What format is expected for the SonarLint config option "Test file regular expressions"?

  • Operating system: Win 10
  • SonarLint plugin version: 7.13
  • Programming language you’re coding in: Java, TypeScript
  • Is connected mode used: No

In the SonarLint preferences in Eclipse, there is an option for “Test file regular expressions”. I am aware that SonarLint already determines test code by the respective build path flag for Java code. But I am wondering what format this config expects if I wanted to use it on top of that.

While it says “regular expression”, the example in the FAQ here (Frequently asked questions) shows **/*Test.java, which looks more like a GLOB than a regex pattern to me.
Does it have to end in a file type, or would something like **/src/test/** work as well?
And since it says “regular expressions” in a plural form, I wonder what kind of delimiter it would need to use multiple patterns.

1 Like

Hello @CrushaKRool

You are right, the name “regular expression” is wrong here. We are expecting a comma-separated list of java glob patterns. I have created a ticket to fix the description.

**/src/test/** is a valid glob pattern, but be careful, the pattern is used against the file relative path in the Eclipse project, and I noticed that Java glob patterns have misleading behavior for relative paths. If src folder is the first folder in your Eclipse project, you might have to use pattern src/test/**.
Or simply set both: **/src/test/**,src/test/**

1 Like

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