0

We have a web solution that uses both C# and javascript. I've gotten a vNext build working that compiles, and runs both C# unit tests, (VSTest task), and a javascript test, using a Jasmine package. The C# tests have been working for some time just fine. Reporting fine in SonarQube. We are just getting the developers started with Javascript, so it is the catalyst for adding a second unit test task.

Both unit test tasks run, a trx file is created by both. One of the peculiarities I've noticed is that the second test task, be it C# or javascript, delete the TestResults directory on the build server. Now this seems fine for TFS reporting, as the coverage appears to include both tests, so the upload there fine. The problem is when it tries to send the results to SonarQube, I was only getting whichever was second in the test order. Once I figured out the deletion of the first set of test results, I was able to use a powershell script to create a 2nd directory to stash the results in, until before the SonarQube end task happens. However, SonarQube doesn't seem to like the 2nd .trx file in the same directory, and picked one of the two, to upload to its server. It spits out a warning that multiple .trx files were found, and picks one to process.

I did find a some information on a Sonar parameter that could be passed in, sonar.cs.vstest.reportPath=. Sonar does pick up the file in the original TestResults folder, but only appears to mention the second, stash directory, as in passing, FYI, not doing anything with it.

I've also tried using a merge process to put the two .trx files together, but SonarQube doesn't see any of the unit tests results when I do that.

My main question here, is there a better way to run two sets of test tasks, with differing languages and runners, and have the results appear in SonarQube in the same project report? Am I attempting something that shouldn't be done, or is there a better way to go about what I'm doing?

1 Answers1

0

There isn't any better way to achieve the feature you want as I know, you need to to run the analysis for each test task like following:

  1. Prepare the SonarQube analysis
  2. Run the test
  3. Complete the SonarQube analysis
  4. Prepare the SonarQube analysis
  5. Run the test
  6. Complete the SonarQube analysis

Similar question here: Can we run the SonarQube for Multiple Project?

Community
  • 1
  • 1
Eddie Chen - MSFT
  • 29,708
  • 2
  • 46
  • 60
  • In the linked question, there is a broken link referencing a views plugin. Has it been moved? – Tony DeJaynes Feb 07 '17 at 23:08
  • @TonyDeJaynes The plugin is replaced by Governance since SonarQube 5.5. https://www.sonarsource.com/why-us/products/plugins/governance.html & https://docs.sonarqube.org/display/PLUG/Views+Plugin – Eddie Chen - MSFT Feb 08 '17 at 06:19
  • Tried the above. Sonar was just showing whichever ran last. So, I've gone the longer route. I've got Chutzpah 4.3.3 running through a DOS command line, with its output being picked up and published, via vNext tasks. http://matthewmanela.com/blog/category/chutzpah/ I then run a Sonar-Scanner instance to pick up the output from Chutzpah, and send it to SonarQube under a javascript project. This project is distinct from the C# SonarQube project. Even though both the javascript and C# are in the same csproj. For now this will work. Not pretty, or simple, but working is working. – Tony DeJaynes Feb 09 '17 at 20:06