[dotCover]DotCover missing coverage for the referenced source DLL - visual-studio-2010

I just started using dotCover,been almost two days but no results. I have a test project 'A' with all the TCs based on unit framework,I have added the code assembly as reference assembly in my project assembly 'B' When I build and run the test cases,everything is executed as expected. What I'm getting is the coverage of my test project 'A' instead of the whole coverage i.e baseline code. like my TC-1 is passed,TC-2…TC-N is passed,and coverage against every TC in % with no reference to underline code.
While going through solutions provided in a couple of other posts I have tried the following options.
1)Adding PDB files of assembly 'B' in the Debug folder of the test project 'A'.
2)Enabling/Disabling the switch unchecking "match with current project structure"
3) Adding the src project in the test project.
4)Using the src project and adding the Test Project as standalone application[nunit] and executing.
In all the above cases,I got the same results.
Coverage of the code of my Test Cases,no results for actual code :(
Plz help to sort this out,this has already taken enough of my time ..:'(

Related

sonarqube not excluding test folder

I am using sonarqube 5.6.1 with gradle plugin 2.1.
I can't exclude test folders from report issues.
property 'sonar.exclusions', 'src/test/, build/'
Test folder is not excluded while build folder is.
I can exclude the whole test folder, however, all my test source and results are gone. Unit test result is important. I need them.
property 'sonar.test.exclusions', 'src/test/**'
How can I archive both exclude test source from reporting issue and showing unit test result?
This is a bug. Sonarqube must provide a way to stop reporting issue in test code. My directive is to fail the build if the quality gate fails. It is not correct to fail my build because test code has quality issue.

Can't get correct assembly filters to work with TeamCity 8 and dotCover code coverage

I have configured a Nunit test runner build step which successfully runs my testsuite, pointing at a test sub-project of my .Net solution eg. Solution/Solution.Test/bin/debug/Solution.Test.dll.
My solution structure is as follows:
Solution
Solution.Lib
Solution.Model
Solution.Test
Lib and Model dlls are referenced in the test project.
I then turned on dotCover without any assembly filters and it performed code coverage analysis on the above test dll correctly.
I then added a filter, -:Solution.Test, and added +:Solution.Lib, and +:Solution.Model to the assembly filters and ran the build configuration, and the build.log reported the following:
Generate dotCover HTML report
[17:15:41][Generate dotCover HTML report] No source files were found under the build checkout directory W:\TeamCity\Install\buildAgent\work\7136872008cbf3bf. No source files will be included in dotCover report as source code of classes.
No executable code was detected.
The issue could be caused by one of the following:
- Include / exclude patterns are incorrect
- Assemblies are compiled without debugging information
- .pdb files are not available
- Visual Studio code coverage is enabled for MSTest
- .testrunconfig is used for MSTest and Visual Studio code coverage is not disabled (CodeCoverage section with enable="true" is present)
So I'm wondering with the above configuration what am I doing wrong, if the paths are correct?
So, I just experienced this myself. While this may not be your issue, I had a bug in my setup that took me way too long to figure out.
Since my application's namespace (and project file name) is Organization.Product, I used that in my test filter. However, it is the name of the assembly that you're filtering on.
And my assembly's output name is Product name with spaces. Yikes.
Anyway, I was able to get it to work with a simpler filter:
-:*Test*
Your filter could simply be:
-:*.Test
I would also say that you don't need to do both inclusions and exclusions. If you do an exclusion, everything else will be included. If you do an inclusion, everything else will be excluded.

Unit Tests are always "successful" after adding OCMock

I would like to use OCMock in my Cocoa project's unit tests. I have downloaded the latest version of OCMock (2.0.1) and copied the OCMock.framework into my project's directory. In Xcode, I have added the framework to the unit test target's link phase. I have then added some code that uses OCMock's classes.
From then on out, all unit tests are reported as "successful" - green light, no errors or warnings. Even after introducing STFail calls, Xcode claims "Test succeeded". Placing a breakpoint in arbitrary test methods reveals that none of them are executed.
The issue persists if I comment out the code using OCMock, including the import directives.
The issue vanishes - i.e., the STFails start failing again - when I remove OCMock from the link phase.
This is similar to another question I've asked before, but not exactly the same: In this case, the info in the Log Navigator shows no errors. What could be causing this behavior? What can I do to diagnose the matter?
It turns out I was missing a Copy Files build phase for the framework, which apparently may lead to a variety of issues.
This works for me:
Add a Copy Files phase to the unit test target's build phases. I positioned it right before the Run Script phase, making it the second-to-last one.
Drag the OCMock.framework item from the project navigator onto the phase in order to add it; adding it using the + button doesn't work in Xcode 4.6 (maybe because frameworks are directories?).
Set the phase's destination to "Frameworks".
In the unit test target's build settings, look for Runpath Search Paths and add the entry #loader_path/../Frameworks.
This way, the unit test executable will be able to find the framework at runtime. Note that you can also use "Products Directory" as the destination of the Copy Files phase, in which case you can skip the fourth step.

gcovr doesn't recognise conditionals from Xcode 4.5

I have an Xcode 4.5 project for iOS 6.0 and I am trying to set up test coverage for Jenkins with Cobertura.
I have set up a test target and have configured both the main target and the test target correctly (Instrument Program Flow and Generate Test Coverage Files both on YES).
When the coverage report is generated (.gcda file), I translate it into XML using the gcovr tool (version 2.4).
When I run the test on Jenkins, everything works fine and I can see the report through the Cobertura plugin. The only problem is that in the Cobertura report all the values for "Conditionals" are "N/A", while I see that there are conditionals (if-constructions) in the covered files.
My guess is that something happens in the translation to XML resulting in a faulty conversion of branches/conditionals, but I cannot find what it is.
The strange thing is that for some if constructions it does recognise the conditional. For example if I use the "STAssertEquals()" macro from the "SenTestingKit" library, the if constructions there are recognised.
I hope someone can help me with a fix for this problem or at least knows the cause. Please do not hesitate to ask me if you need more information.
Nicolas

VS 2010 - Code Coverage Results includes the test project itself

I am writing some unit tests for one of my DLL libraries.
The 'Code Coverage Results' pane shows a breakdown of the assemblies covered and tested.
For some strange reason - my test project itself appears in the coverage results ! (at approx. 90% covered).
This seems stupid... what's the deal with this ?
The reason the percentage is so high is that projects for code coverage are instrumented to keep track of which lines are hit by a test run, since you are running the tests from this project, almost all lines of code in the project will be run.
You can choose which projects/DLLs to collect Coverage statistics on in the Test Settings.
So if you don't need to capture stats on the test project (which you shouldn't really), you can simply remove this project from the settings you're using for coverage.
See http://msdn.microsoft.com/en-us/library/ms182534.aspx (steps 5 - 7 in particular) for more details.

Resources