Sonarqube: Test coverage comes as 0 - unit-testing

I am using sonar integration for the c# x unit test project. But always test coverage is coming as 0. How can I resolve this

coverlet is the nuget responsible for sonar integration to x unit test projects. Adding coverlet.msbuild and coverlet.collector nuget resolve the issue.

Related

TFS vNext build Test Impact Analysis- Impacted unit tests are not running at all

I have a VB Solution having 1 project and corresponding unit test project in it.
TIA is enabled. But during code check-in, impacted unit tests are not getting executed.
If I add any new method and then write the corresponding unit test, then TIA is running newly added unit test only as part of impacted unit test.
Any clue, why my impacted unit tests are not getting triggered.
Thanks in advance...

Nunit tests are not found on tfs 2013 although NUnit test adapter package is used

I have a simple application and Nunit unit test project with 2 tests to test that app.
I've managed to have unit tests discovered and run locally in Visual studio 2013 but when trying to build application and run these unit tests on TFS 2013 test runner does not find tests ( both projects are built successfully.
No test found. Make sure that installed test discoverers & executors, platform & framework version settings are appropriate and try again.
I've added "NUnit adapter with framework" package to Unit tests project according to answer in this question and committed changes to the TFS.
Unit tests projects is successfully built but still no tests are found. The Test dll fits the **\*Test*.dll naming pattern as configured in the Build Definition.
Why no tests are found? How I can make sure Test Runner is aware of my NUnit test adapter?
If you go to the build, and look in diagnostics (from the web portal), there is a Run VS Test Runner section.
In the same log, there is a Run MSBuild section, it should say "Successfully installed xxxx" where xxx is the name of your adapter package.
Something like:
Check to see that the test runner is successfully restored.
Found the reason - build agent folder in source settings of Build definition was not set correctly - instead of setting it somewhere under build agent working folder I set it outside of it that's why unit tests were not found..
I discovered this using Build process activity log (which was saved in drop folder in my case).this log contains very detailed information (much more than you can see in Visual studio) - there I found in which location test runner is looking for unit tests and then understood what i did wrong.
That's what I saw in log:
Run VS Test Runner00:00:00
Inputs
TestSpecs: BuildParameter[] Array
Enabled: True
ConfigurationsToTest: String[] Array
OutDir:
There were no matches for the search pattern C:\Builds\11\XXXX\Application -Gated\bin\**\*Test*.dll
Hope this will be helpful to someone else.
thanks to everyone who responded to my question!

decrease in unit test success in sonar

Recently i have upgraded sonar from 3.1.1 to 3.2.1. There is a decrease in unit test success leading to decrease in code coverage. In 3.1.1 there were no errors after unit test and 100%unit test success, but in 3.2.1 about 267 errors generated after test resulting 93% unit test success.
could someone tell me what to do to get 100%success in unit test?
thanks in advance.

How to unit test in ScriptSharp

We noticed that there was a unit testing project within the latest Script# 0.8 code on the Git repository, but there is no documentation as to how to actually use it, and the example files don't seem to work correctly.
Having stepped through the source code, we can't actually see any test code within the unit test files.
Has anyone else managed to successfully run unit tests against Script# within the Visual Studio IDE?
The AroundMe sample at https://github.com/nikhilk/scriptsharp/tree/cc/samples/AroundMe demonstrates unit testing.
In short, there are two parts -
1. The Tests subnamespace within your project containing tests alongside code being tested. Test code gets split out by the compiler to generate a Foo.test.js alongside Foo.js and Foo.debug.js.
A test project which provides a driver to launch unit tests in browser and capture results of QUnit to surface into VS unit testing UI. This is optional... you could run the Foo.test.js manually using QUnit yourself if you've got your own pipeline for executing tests.
Hope that helps.

integration test - unit test seperation and best practices with visual studio 2010 + tfs

In our big application written with C# we have automated tests.
Some of tests are integration tests; they are mostly testing integration points with other systems, they are slower than unit tests and to get them to succeed on a new machine some configuration is needed.
Some are unit tests; they are much faster, do not need any configuration.
In related test projects we have two folders in general: UnitTest and IntegrationTest. Hence I have not an option to run them seperately.
What I need is, clear seperation between unit and integration tests. I want to be able to run only integration tests or just unit tests.
How can I achive this seperation? What are your experiences on the subject?
In visual studio go to the Test menu > Windows > Test List editor. All test methods can be selected/deselected in this window. At the top left click the arrow and choose Run checked tests or debug checked tests.
You can also use the TestCategory attribute (just Category in NUnit). Then run the tests in that category.
something like TestCategory("Unit") or TestCategory("Integration")