SonarCloud Gitlab CI does not analyze test projects

Hi, I use Gitlab CI for automation. My project is on .Net Framework 4.6. The problem is that SonarCloud does not analyze my test projects in a solution. I have .sonarcloud.properties:

# Path to sources
sonar.sources=.
#sonar.exclusions=
#sonar.inclusions=

# Path to tests
#sonar.tests=.
#sonar.test.exclusions=
#sonar.test.inclusions=./ProcessFlowModuleDotNetV1.Tests 

# Source encoding
sonar.sourceEncoding=UTF-8

# Exclusions for copy-paste detection
#sonar.cpd.exclusions=

and this is my stage:

sonarcloud-check:
  stage: sonarcloud-check
  image:
    name: sonarsource/sonar-scanner-cli:latest
    entrypoint: [""]
  cache:
    key: "${CI_JOB_NAME}"
    paths:
      - .sonar/cache
  dependencies:
    - build
    - test
  script:  
    - echo "${CI_JOB_NAME}"
    - SonarScanner.MSBuild.exe begin /k:"semansys_xbrlonecompliant" /o:"semansys" /d:sonar.verbose=true /d:sonar.host.url="https://sonarcloud.io"  /d:sonar.login="token"   
    - nuget restore -ConfigFile .\nuget.config
    - MsBuild.exe ./  /t:Rebuild
    - SonarScanner.MSBuild.exe end /d:sonar.login="token"

This file is not used when you analyze your project on GitLab. This file is only used when using the Autoscan feature, which is currently only available on GitHub. For your purpose, you need to rename the file to sonar-project.properties.

With the configuration change above, I hope you will be able to resolve your main issue. Some additional notes that may help:

I hope this help, let us know how it goes!

2 Likes