0
votes

I am using sonar analysis for a project. I am unable to get code coverage because tests are giving errors when I run with Gallio.

If I run the same unit tests with nunit-console.exe all of them are passing. (I am running this in administrator mode of cmd)

But they are failing when I run them with gallio. Anyone had this issue before?

This is what I get when I run with sonar gallio.

03:51:30.754 INFO - 101 run, 7 passed, 94 failed (94 error), 0 inconclusive, 0 skipped 03:51:30.754 INFO - 03:51:30.910 INFO - Committing... 03:51:31.238 INFO - Visited Classes 11 of 20 (55) 03:51:31.238 INFO - Visited Methods 16 of 80 (20) 03:51:31.238 INFO - Visited Points 66 of 519 (12.7167630057803) 03:51:31.238 INFO - Visited Branches 7 of 122 (5.73770491803279) 03:51:31.238 INFO - 03:51:31.238 INFO - ==== Alternative Results (includes all methods including those without corresponding source) ==== 03:51:31.238 INFO - Alternative Visited Classes 11 of 25 (44) 03:51:31.238 INFO - Alternative Visited Methods 23 of 166 (13.855421686747) 03:51:31.488 INFO - Sensor org.sonar.plugins.csharp.gallio.GallioSensor@964f8e done: 22314 ms 03:51:31.488 INFO - Sensor ProfileSensor... 03:51:32.145 INFO - Sensor ProfileSensor done: 657 ms 03:51:32.145 INFO - Sensor ProfileEventsSensor... 03:51:32.160 INFO - Sensor ProfileEventsSensor done: 15 ms 03:51:32.160 INFO - Sensor ProjectLinksSensor... 03:51:32.160 INFO - Sensor ProjectLinksSensor done: 0 ms 03:51:32.160 INFO - Sensor VersionEventsSensor... 03:51:32.176 INFO - Sensor VersionEventsSensor done: 16 ms 03:51:32.176 INFO - Sensor org.sonar.plugins.csharp.gallio.TestReportSensor@412739... 03:51:32.957 INFO - Sensor org.sonar.plugins.csharp.gallio.TestReportSensor@412739 done: 781 ms 03:51:33.410 INFO - Execute decorators...

when I run it with Nunit-console.exe from command line. I get the same results. But when I run it with Nunit-console.exe from command line as an ADMINISTRATOR. I get the following output:

Tests run: 101, Errors: 0, Failures: 0, Inconclusive: 0, Time: 27.3760719 seconds Not run: 0, Invalid: 0, Ignored: 0, Skipped: 0

So I think I need to run these tests as a administrator from Sonar. How do I do that?

Also I tried running these tests from (gallio) Icarus GUI Test Runner as ADMINISTRATOR and all of them passed. They are not passing if I run in regular mode.

1
Can you please add the log excerpt that shows the failure?Fabrice - SonarSource Team
@Fabrice-SonarTeam Thanks for your reply. I have added more information to my post. Would you have any suggestions regarding this?user2463926

1 Answers

0
votes

If the unit test exection succeeds when launching it as an administrator, you should wonder why your tests require such rights to get executed correctly.

A first solution to make your analysis pass is to run the Sonar analysis as an administrator: the Gallio command will be run using the same user and it should therefore succeed.

A second (and better) solution is to rework your tests and/or their configuration to make sure that they do not require admin rights to succeed.