Unsupported framework error NUnit and MonoDevelop - nunit

I have latest versions of MonoDevelop(5.10) and NUnit(3.6.1 installed from oficiall NuGet Gallery) and every time I'm trying to run tests I'm getting error
UnsupportedFrameworkException: Skipped loading assembly ... because it references an unsupported version of the nunit.framework 3.6.1.0
What can I do about it ?

You are apparently trying to run the tests from inside of MonoDevelop, which only supports NUnit through 2.4.8.
You need to install and run the nunit console runner. Use the NUnit.ConsoleRunner nuget package and run nunit3-console, which is contained in the package.

Related

Nuget package is not compatible, but in the supported-list (StrawberryShake.Tools)

I got this message after creating a new .NET 5-project (in VS2019) and trying to install nuget-package StrawberryShake.Tools. This seems a bit strange, since it says both that it is and it isnt compatible with "net5.0 (.NETCoreApp,Version=v5.0)"
Error NU1202 Package StrawberryShake.Tools 12.6.0 is not compatible
with net5.0 (.NETCoreApp,Version=v5.0). Package StrawberryShake.Tools
12.6.0 supports:
net5.0 (.NETCoreApp,Version=v5.0) / any
net6.0 (.NETCoreApp,Version=v6.0) / any
netcoreapp3.1 (.NETCoreApp,Version=v3.1) / any
I had the same problem, so I followed the official installation guide instead. The steps are as follows:
Open a terminal and navigate to e.g. the project where you want the package to be installed.
Run dotnet new tool-manifest.
Run dotnet tool install StrawberryShake.Tools --local. The nuget package has now been installed in ~/.nuget/packages and may be used in the project.

CakeBuild: Get failed to install tool 'NUnit.ConsoleRunner'

I used CakeBuild to build and test my Xamarin Portable Class Library.
In the build.cake script I defined that I want to use the NUnit-Console to run my testcases. So I do
#tool nuget:?package=NUnit.ConsoleRunner
Unfortunatelly I get the following error when I run the Cake script.
Preparing to run build script...
VERBOSE: Restoring tools from NuGet...
VERBOSE: Feeds used:
C:\Users\bergkar\.nuget\packages\
All packages listed in C:\dev\Xamarin\fleetboard-core-library\tools\packages.config are already installed.
Running build script...
Analyzing build script...
Processing build script...
Installing tools...
Unable to find package 'NUnit.ConsoleRunner'
NuGet exited with 1
Could not find any relevant files for tool 'NUnit.ConsoleRunner'. Perhaps you need an include parameter?
Error: Failed to install tool 'NUnit.ConsoleRunner'.
When I add a specific version I want to use like below then everything works fine.
#tool nuget:?package=NUnit.ConsoleRunner&version=3.7.0
Can someone tell me why it is not working without the version stuff?
With ".\build.ps1 -Verbosity Diagnostic" I get the following output:
Preparing to run build script...
Running build script...
Module directory does not exist.
Analyzing build script...
Analyzing C:/dev/Xamarin/fleetboard-core-library/build.cake...
Processing build script...
Installing tools...
Installing NuGet package NUnit.ConsoleRunner...
Executing: "C:/dev/Xamarin/fleetboard-core-library/tools/nuget.exe" install "NUnit.ConsoleRunner" -OutputDirectory "C:/d
ev/Xamarin/fleetboard-core-library/tools" -ExcludeVersion -NonInteractive
Unable to find package 'NUnit.ConsoleRunner'
NuGet exited with 1
Feeds used:
Output:
Feeds used:
Could not find any relevant files for tool 'NUnit.ConsoleRunner'. Perhaps you need an include parameter?
Error: Cake.Core.CakeException: Failed to install tool 'NUnit.ConsoleRunner'.
at Cake.Core.Scripting.ScriptProcessor.InstallTools(ScriptAnalyzerResult analyzerResult, DirectoryPath installPath)
at Cake.Core.Scripting.ScriptRunner.Run(IScriptHost host, FilePath scriptPath, IDictionary`2 arguments)
at Cake.Commands.BuildCommand.Execute(CakeOptions options)
at Cake.CakeApplication.Run(CakeOptions options)
at Cake.Program.Main()
Now I found my problem and solved it.
The problem was that the NuGet.exe did not has a source feed which points to a public nuget source like "https://api.nuget.org/v3/index.json".
This was because my default NuGet.conf in under "C:\Users\YOUR_USER_HOME\AppData\Roaming\NuGet" had no packageSource defined. So Nuget just knows the local nuget package cache under "C:\Users\YOUR_USER_HOME.nuget\packages" and this did not include the specified package.
So after I added a packageSource in "C:\Users\YOUR_USER_HOME\AppData\Roaming\NuGet\NuGet.Conf" everything works fine.
Another way can be to add a new NuGet.Conf beside your build.ps1 file which contains all package sources you need for CakeBuild and your Xamarin project.
The following page explains how Nuget finds its configuration. Maybe this is helpful to understand the mechanism NuGet uses to find its configuration:
https://learn.microsoft.com/en-us/nuget/consume-packages/configuring-nuget-behavior

NuGet restore works if old version 0.*, but fails with version 2.*

I've got a VSTS build, starting from a blank, originally with just Node.js bits, but now adding some C# bits.
Added the NuGet restore, build sln and vstest tasks as part of the update to the build.
Build fails on the NuGet restore task with the error around the MSTest TestAdapter ...
Restoring NuGet package MSTest.TestAdapter.1.1.11.
Restoring NuGet package MSTest.TestFramework.1.1.11.
WARNING: Unable to find version '1.1.11' of package 'MSTest.TestFramework'.
WARNING: Unable to find version '1.1.11' of package 'MSTest.TestAdapter'.
Errors in packages.config projects
Unable to find version '1.1.11' of package 'MSTest.TestFramework'.
Unable to find version '1.1.11' of package 'MSTest.TestAdapter'.
Why doesn't it pick up the MSTest package?
And even more puzzling to me ??? ...
I spotted the task was version 2.*
tried setting it to version 0.* ...
and the build works !! ... runs tests, etc.
Why does version 0.* work, yet the latest version 2.* fails?

Nunit 3.2.1 Tests not discovered on Visual Studio Test explorer

This is my configuration:
Visual Studio Enterprise 2015
NUnit 3.2.1
NUnit3 Test Adapter 3.0.10 (Installed as Extensions and Updates as well as through nuget package manager in project)
Target Framework is set to 4.5
Build succeeds fine but test discovery shows an error and 0 tests are discovered.
Error log:
Exception NUnit.Engine.NUnitEngineException, Exception thrown discovering tests in C:\projects\~
The NUnit 3.0 driver does not support the portable version of NUnit.
Use a platform specific runner.
NUnit Adapter 3.0.10.0: Test discovery complete.
Discover test finished: 0 found
When running the NUnit 3 Adapter (correct name) version 3.0.10, you are using NUnit 3.0.1 to run your tests. If the tests use the 3.2.1 framework, then there is some chance of an incompatibility. NUnit runners are always backward compatible. For example, you could use NUnit 3.2 to run NUnit 3.0 tests, but the reverse is not true.
The message you are seeing is actually misleading and was changed in the code recently. It assumes you are runing a portable test when a serialization exception occurs.

How can I run EntityFramework 7 tests?

I followed the steps here and have EntityFramework 7 building in VS2015.
Under RunTests the instructions above note the following:
Our tests are written using xUnit.net 2.0, and can be run using your
favorite runner. We recommend either the built-in Visual Studio test
runner or TestDriven.Net.
In VS2015, executing Test > Run > All Tests results in:
------ Discover test started ------
========== Discover test finished: 0 found (0:00:00.0990702) ==========
Taking a look at Running xUnit.net tests in Visual Studio reveals that you need to:
Search for (and install) a package named xunit.runner.visualstudio
However doing so results in a failed install, for either the current stable or prerelease package;
Resolving conflicts for DNXCore,Version=v5.0...
Unable to find a version of package 'System.Dynamic.Runtime' that is compatible with version constraint '[4.0.0, )'.
Unable to find a version of package 'System.Text.RegularExpressions' that is compatible with version constraint '[4.0.10, )'.
Unable to find a version of package 'System.ComponentModel' that is compatible with version constraint '[4.0.0, )'.
Unable to find a version of package 'System.IO.FileSystem' that is compatible with version constraint '[4.0.0, )'.
Unable to find a version of package 'System.Collections.Concurrent' that is compatible with version constraint '[4.0.0, )'.
========== Finished ==========
NotFound https://az320820.vo.msecnd.net/v3-flatcontainer/microsoft.framework.primitives/index.json 1078ms
How can I run the tests without a TestDriven.Net license?