NCover free Version for multiple solutions - c#

I am using NCover 1.5.8 which comes with TestDriven.Net 3.0. I am using NCover for Visual studio 10.0.
I have 26 Solutions and each solution having about 10-30 projects total is about 560 projects. I use a common directory for building all solutions.
When I am running NCover for a single file or for a project or even for a complete solution then it's working fine but I am unable to run NCover for all the 26 solutions at a time.
All the 26 solutions belongs to a single software product and many projects having cross solution DLL reference so I need coverage according to that. I have also tried to run it using console but in case of console I am getting empty coverage XML file.
I am using NUnit 2.5.10, NCover 1.5.8, TestDriven.Net 3.0, Visual Studio 2010 professional, Windows 8 64 bit.

Related

Why is CodeCoverage.exe producing near empty .coverage Files?

In our Jenkins pipeline, we use SonarQube to report on our code coverage. After running all of our unit/integration tests to produce the .coverage file, we need to analyze this file to create the ".coverage.coveragexml" which is ultimately what is used by SonarQube to interpret the code coverage. We do this by using the CodeCoverage.exe:
"C:\Program Files (x86)\Microsoft Visual Studio\2022\TestAgent\Team Tools\Dynamic Code Coverage Tools\CodeCoverage.exe" analyze /output:"{somePath}\{someName}.coverage.coveragexml" "{somePath}\{someName}.coverage"
This command appears to be working, but when you run dir /s *.coveragexml (within the directory), it displays something like:
Directory of C:\jenkins\path\to\TestResults\coverageFile
03/22/2022 04:59 PM 64 ContainerAdministrator_DC420D3FA0BA_2022-03-22.16_46_43.coverage.coveragexml
1 File(s) 64 bytes
64 bytes is practically nothing - and I believe this is the reason why our SonarQube metrics show we have 0 coverage now.
I added the same dir command, only this time to check for the .coverage file(s), and those come back with only 10 bytes in them - making me think that these files are essentially empty. I saw this post that seems to be a similar issue. The accepted answer said to change the platform type from x86 to x64, but that did not work in my case.
The vstest.console command for running our tests is:
vstest.console /Parallel /EnableCodeCoverage /Logger:trx /Platform:x86 ".\somePath\Test.dll"
This issue originally started back when we made a change to our Jenkinsfile for it to use Visual Studio 2022 instead of 2019 (the base image was updated) in the command that started the CodeCoverage executable.
What could be causing the coverage files to be nearly/completely empty and how can I fix it?
It seems the base image we use must have a non-enterprise edition of the Code Coverage tools (which is a requirement). We tested our SonarQube projects commands locally using an enterprise edition of the tools (I have Visual Studio 2022 Enterprise installed on my machine), and the coverage files produced contain the correct data. However, when we used a Visual Studio Professional install, the files are empty just like our Jenkins pipeline.
As stated, this started happening when the base image was updated - in particular it was around November 8th 2021. It seems the base docker image we were using (mcr.microsoft.com/dotnet/framework/sdk:4.8-20220210-windowsservercore-ltsc2019) has the latest 2022 tools, but it must not be an enterprise edition - hence the empty files.
We switched our pipeline over to using dotCover instead to perform the analysis, which works as expected and our SonarQube coverage is back to normal.

C# Nunit tests from VS 2013 (Nunit v2.x), won't show in Test Explorer in VS 2017 (Nunit 3.x)

Good Morning
Note: I am new to VS and C# coding. Learning and have the following issue.
PROBLEM STATEMENT:
C# Nunit tests from VS 2013 (Nunit v2.x), won't show in Test Explorer in VS 2017 (Nunit 3.x)
BACKGROUND:
Recently identified good scripts for our application written with VS 2013 with C# based on NUnit 2.x.
I have copied them into my machine with VS 2017 and Nunit v.3.10.1 and Nunit3TestAdapter v.3.10.0.
Note: The Tests are running fine in another machine with VS 2013 and Nunit v2.x
Machine and VS config:
- Windows 10 pro 64 bit OS with 64 bit processor
- VS 2017: Default Processor Architecure is set to X64
- At present, "Active Solution Platform" is set to X86 for build settings for my test project (Build > Configuration Manager).
- VS Nuget Package for Nunit: v.3.10.1
- VS Nuget Package for Nunit3TestAdapter: v.3.10.0
What i have done or tried:
- The test project cs file contains [TestFixture] and [Test] in the correct places
- I have tried cleaning / rebuilding the solution multiple times
- I have tried restarting Visual Studio multiple times
- I researched many articles here and in other venues
- Can't get a straight answer yet if it is possible, or impossible or what is the solution.
Thank you very much!
Andrew
Install NUnit3TestAdapter Visual Studio plugin.
In Visual studio, go to Tools -> Extensions and Updates. At the dialog, choose Online from navigation pane, and in the search bar type NUnit, pick the NUnit 3 Test Adapter plugin and install it. Once done, you will be required to restart Visual Studio and rebuild your test project.
With the help of my friend Fahad, the issue seems to be resolved with the following steps:
Unistalled Nunit3TestAdapter v.3.10.0 and Nunit3 v.3.10.0
Manually removed all the "nunit.*" references
Installed the following via NuGet:
Nunit3 v.3.10.1 and Nunit3TestAdapter v.3.10.0
Nunit.ConsoleRunner v.3.8.0
Updated VS 2017 to the version 15.7.3
So at this point I see all the Tests in the Test Explorer. I have another issue with them not running due to this (but possible it is a different issue):
Warnings for not able to run Tests

How to install MSBuild tools on Win 10 32-bit machine without Visual Studio

I have two machines:
- dev machine --> Win 10 64-bit with Visual Studio 2015
- test machine --> Win 10 32-bit machine without Visual Studio (no version is available)
I have developed DB & Web API apps on 64-bit machine and would like to compile those projects on 32-bit machine.
I have installed Win 10 SDK and also VS 2015 build tools but after those installations, 32-bit machine doesn't have following:
Program Files\MSBuild\Visual Studio
Without those, I can't run my batch files to compile those projects. Any idea how do I get those MSBuild related files? (in my 64-bit machine, I can see SSDT & WebApplications folders which are necessary for compiling DB & Web API projects and I need same on another machine.)
First off, Visual Studio (VS), SSDT, and MSBuild are separate but related applications. VS installers don't so much install just VS but the typical VS suite of apps which includes MSBuild for most flavors.
If you're setting up a 'build machine' and want to manually shoot over builds to MSBuild, you can use this Microsoft Build Tools 2015 https://www.microsoft.com/en-us/download/details.aspx?id=48159
However, if you're getting a continuous integration set-up up and going, there are a bunch of options and services. visualstudio.com has some options.
I personally like TeamCity (Subversion, Test & Build) + Octopus Deploy (pushes builds to the right environment).
Team City can be set-up for a variety of version control and build runners. The free/intro version is full-featured. Octopus' intro version will work for small teams. Both products are well-supported and documented.

ReSharper Unit Test not run in bin directory

Preamble
I know, that this question seems to have anwsers here:
Resharper runs UnitTest from different location
Resharper Unit Test Runner Can't Find Content Files
I have nearly the same problem like ReSharper 10 test runner failing to find AppSettings referenced from external file.
But these answer stated, that the problem should be gone with ReSharper 10.0.2
Question
I included a custom.xml files with custom settings, and I need to read them from my unit test. But my file is not found.
I looked, where the process runs, and included this line
var curdir = Directory.GetCurrentDirectory();
So I found out, that curdir is C:\\Users\\MYUSER\\AppData\\Local\\JetBrains\\Installations\\ReSharperPlatformVs11_000
Now it is obvious that my file cannot be found. After googling it, it found the above mentioned questions. But none of these solutions works for me.
These are my settings:
Visual Studio Configuration
Microsoft Visual Studio Ultimate 2012
Version 11.0.61219.00 Update 5
Microsoft .NET Framework
Version 4.6.01038
Installierte Version: Ultimate
Architecture and Modeling Tools 04940-004-0038003-02857
Team Explorer für Visual Studio 2012 04940-004-0038003-02857
Microsoft Team Explorer für Visual Studio 2012
Visual Basic 2012 04940-004-0038003-02857
Microsoft Visual Basic 2012
Visual C# 2012 04940-004-0038003-02857
Microsoft Visual C# 2012
Visual C++ 2012 04940-004-0038003-02857
Microsoft Visual C++ 2012
Visual F# 2012 04940-004-0038003-02857
Microsoft Visual F# 2012
Windows Phone SDK 8.0 - DEU 04940-004-0038003-02857
Windows Phone SDK 8.0 - DEU
ASP.NET and Web Tools 2012.3.41009
GenerateUnitTest 1.0
Git Source Control Provider 1.0.0.0
JetBrains ReSharper Ultimate 10.0.2 Build 104.0.20151218.120627
Microsoft Advertising SDK for Windows Phone 6.2.923.0
Microsoft Advertising SDK for Windows Phone Build 6.2.923.0
Microsoft XNA Game Studio 4.0
Microsoft XNA Game Studio 4.0
NuGet-Paket-Manager 2.8.60318.667
PreEmptive Analytics Visualizer 1.0
SQL Server Data Tools 11.1.20627.00
Microsoft SQL Server Data Tools
Git Extensions
You don't list any version of NUnit installed, but you tagged this 'nunit' so I'm going to make an assumption you are using it! Further, I'm assuming NUnit >= 3.0... ignore this if otherwise. :-)
NUnit 3.0 stopped changing current directory. It's a bad idea for us to do that anyway and it's a really bad idea with 3.0, when multiple assemblies in differing directories may be running at the same time.
So, assuming still it's an NUnit problem, instead of using a relative path, use TestContext.CurrentContext.TestDirectory as the location of your file.
try this:
Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory);
In my case was fixed when I changed to this setting
The thing that helped me with such issue - I just turned off NUnit 2.x support in ReSharper settings (ReSharper -> Options... -> Tools -> Unit Testing -> NUnit).
I also turned off NUnit 2.x support and even if it has obviously nothing to do with the problem, it solved it (I have ReSharper 2017.3.20180201.111630)
We are using TestCaseSource in our tests.
So the fix for me in Rider version 2021.1.3 was to change Build-->Unit Testing-->NUnit to Test Runner

Create a MSBuild file in vs 2010

I have a web application build on .net 3.5 that is built using VS 2010 pro edition. I am trying to automate the build task for msbuild. Is there a way to make a build file of my project in VS 2010? Or do I have to make the build file from scratch?
There's a tool that can help you creating your own msbuild file and it also has GUI, MS Build Sidekick:
http://www.attrice.info/msbuild/
MS Build Sidekick isn't free but it's quite cheap (US$55), and they also offer trial version for 14 days.
you need to do it from scratch... file->new->text file...
pretty good tutorial on msdn: http://msdn.microsoft.com/en-us/library/dd576348.aspx

Categories