I am using sonarqube to check the code quality of my test scripts.I dont have the main source code in my project as It only consists test scripts. After building my project I am getting message “The main branch of this project is empty.” and all metrics are 0 on sonar dashboard.What should I do if I have to check the quality of test script also.
I have tried to explicitly define sonar.source to src/test/java but It didnt work at all.Please help
Somehow your definition of sonar.sources isn’t working. You wrote sonar.source. Was that a typo in your composition of this post, or is that actually what you set? Because the recognized parameter ends with an ‘s’.
BTW, you’re seeing the message that your project is empty because your files are being analyzed as tests and so no LOC count is being calculated. It’s that metric, specifically, that the project homepage keys on to know whether or not to draw itself. Once you get sonar.sources sorted out, this problem should go away.
BTW, how are you analyzing? With Maven? And what’s your analysis command?
Thank you so much for the reply and sorry for too much delay in the reply.Actually it was a typo in sonar.source. I used exact sonar.sources in the configuration but it didnt work.
I have defined sonar.sources in build.gradle file as:
Still it shows “The project is empty”.
I don’t know whether it is analyzing my project or not. And if it is analyzing then why it is not showing any bug, vulnerability or defect etc.
Actually the project which you provided above consist a main source file (App.java) whose unit test is written in AppTest.java in test folder. So here the sonar will analyse the code because main source code is available but my primary problem is that my framework does not consist main source code as I have a automation testing framework which have no main package (only consists test scripts in test folder).Can you please check it without source code.
I think at this point it will be useful to use the sonar.scanner.dumpToFileparameter (you’ll need to provide a file name as the value) so we can see what value sonar.sources, and also maybe sonar.tests actually end up with.