Error observed (wrap logs/code around with triple quotes ``` for proper formatting)
Last analysis has warnings
Analysis ID "AZMyOcZ12mM7fGQ6k0tM"
Your project contains only TEST-code for language C# and no MAIN-code for any language, so only TEST-code related results are imported.
Steps to reproduce
We have a separate test project that contains specflow (and xunit) BDD style tests, ideally we would like to use sonar cloud to scan the cSharp code written for the step definitions, but we have been able to configure sonar to treat the test project as code to scan.
We are using a Azure yaml pipeline and have tried several different configurations, including properties such as;
But every time the sonar analysis reports that the project only contains test code. Any ideas; is there anything in the above analysis that could help? AZMyOcZ12mM7fGQ6k0tM
I’ve also reviewed the documentation provided, but could not find anything that would point to the cause.
Thanks in advance for any help or suggestions you might have.
I am not sure I understand your configuration.
Could you detail the architecture of your repo in terms of projects, and what type of code you would expect SonarQube Cloud to find in it?
Certainly, more specifically, we have a donet core solution that contains an implementation of a SpecFlow test project.
While we might typically exclude test projects, in this case, we want to ensure that the implementation of the Steps within the BDD / Gerkin feature files meets our quality guidelines, etc.
The solution structure is approximate;
(I’ve created some example step definitions to demonstrate the cs code we want to be scanned).
Within these steps you will find test code, (using xunit) to asset for the THEN phase of the Given When Then, gherkin syntax.
OK, as I suspected your solution only contains test code, which is what the scanner is telling you.
If you want, you can tweak the analysis by asking it to consider this as MAIN code (which will also enable many more rules, as we do not enable them on TEST code).
As indicated in the documentation, you can include the following in your csproj:
Thanks Denis, let me give that a try, I was hoping it could be managed via sonar properties, watch this space, I’ll test and report back; thanks again.
Update - That seems to have done the trick, despite the other settings, it was the project group that was required. Thanks again.