Sonarqube java custom rules unable to run the example test

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
  • what are you trying to achieve
  • what have you tried so far to achieve this

I am following the custom rules 101 to run MyFirstCustomCheck, the version of sonarqube is 8.9.2LTS.
When I am trying to run the test, the error pops on

java.lang.IllegalStateException: Unable to read file '/Users/zhangruibo/Documents/sonarqube/sonar-java/docs/java-custom-rules-example/src/main/java/src/test/files/MyFirstCustomCheck.java'

The codes in my files are the same as the docs asked to write. Clearly, the path has some problem, it should not go to the /src/main/java then go to /src/test/files. Need some help about this issue.

Hello @Ruibo_Z
It looks like the path mixes the location of your check
.../sonar-java/docs/java-custom-rules-example/src/main/java/
with the location of the file you want to run your test on
src/test/files/MyFirstCustomCheck.java

From that point, you can look at 2 things:

  1. Check that the path is the same one given in the documentation
  2. Check that you are launching your test from the right folder/context. It might be that the root folder of the java-custom-rules is not properly recognized.

Cheers,

Dorian