Unsupported test framework error in NUnit - c#

I am using NUnit testing with Visual Studio 2013. We are using NUnitTestAdapter for integration of test run of NUnit with Visual Studio.
Visual Studio 2013
NUnit is version="3.0.1"
NUnitTestAdapter version="2.0.0"
.Net Framework 4.5.2
All packages are latest & installed from Nuget. There is no build error.
We are getting error in test result window:
Attempt to load assembly with unsupported test framework in D:\JuniorAchievement\Git\jaums\JA.UMS.Tests\bin\Debug\JA.UMS.Tests.dll
while running or debugging test using Visual Studio Test Explorer.
Test is able to run on one machine with same code on Visual Studio 2013 ultimate. We all other have Visual Studio 2013 professional version, although I doubt it has nothing to do with the problem.
Please Help.
Update
__________
After update to NUnit3 Test Adapter no error but still no test are discovered.
Somehow both Adapter are available but with Nuget & VS extension I can find only
NUnit3 Test Adapter.
Installed NUnit3 Test Adapter from https://visualstudiogallery.msdn.microsoft.com/0da0f6bd-9bb6-4ae3-87a8-537788622f2d

It looks like you are trying to run NUnit3 tests with the NUnit2 Test Adapter. This is not supported.
You need to install the NUnit3 Test Adapter through Tools > Extensions and Updates in Visual Studio.

NUnit 3.x.y (NUnit 3.4.1) is compatible with NUnit3TestAdapter 3.x.y (NUnit3TestAdapter 3.4.0)
NUnit 2.x.y (NUnit 2.6.4) is compatible with NUnitTestAdapter 2.x.y (NUnitTestAdapter 2.0.0)
If you use NUnit 3.x.y you have to install NUnit3TestAdapter 3.x.y instead of NUnitTestAdapter 2.x.y
I am using Microsoft Visual Studio Community 2015 and Microsoft .NET Framework 4.x
Steps to follow for installation:
1. Open Visual Studio and create a project
2. Right click on project -> Click on "Manage Nuget Packages..." from context menu
3. From pop up window: Install NUnit 3.x.y and NUnit3TestAdapter 3.x.y
4. Now run your tests

NUnit 3 only runs with NUnit test adapter 3 or latest version since there is compatibility issue with the older version 2.0.
so if you have an exception like this:NUnit VS Adapter 2.0.0.0 discovering tests is started
Attempt to load assembly with unsupported test framework in c:.......
NUnit VS Adapter 2.0.0.0 discovering test is finished
then all you need to do is to install the latest version of NUnit and NUnit test adapter on to your project be right clicking referencence on your solution explorer and manage Nuget packages.

run Install-Package NUnit3TestAdapter -Version 3.10.0 on your Package Manager Console.

Run this package manange console.
PM> Install-Package NUnit3TestAdapter -Version 3.10.0
Make sure that, you have selected the nuget.org in package source dropdown and selected the Test project in Default project dropdown.

Related

The NUnit 3 driver encountered an error while executing reflected code (NUnit.Engine.NUnitEngineException)

I have a simple Nunit project which contains only a single test. I want to execute my code using command, so I have installed ‘Nunit-console.exe’ on my Windows 10 machine. After installation, executed the code on command prompt using below command
nunit3-console.exe "G:\LiveProjects\NUnitTestProject2\NUnitTestProject2\bin\Debug\netcoreapp3.1\NUnitTestProject2.dll"
like so
After executing this command, I have discovered below error message:
NUnit.Engine.NUnitEngineException : The NUnit 3 driver encountered an error while executing reflected code.
----> System.InvalidCastException : Unable to cast transparent proxy to type 'System.Web.UI.ICallbackEventHandler'.
--NUnitEngineException
The NUnit 3 driver encountered an error while executing reflected code.
like so
Please refer my below code:
[TestFixture]
public class Tests
{
[SetUp]
public void Setup()
{
Console.WriteLine("Welcome setup");
}
[Test]
public void Test1()
{
Console.WriteLine("Welcome first Test ");
Assert.Pass();
}
}
like so
Configuration details of my project:
Microsoft.NET Framework version 4.7.0
OS: window 10
IDE: Visual studio 2019
Use Nunit framework for unit testing
NUnit3TestAdapter (Version) 3.16.1
Microsoft.NET.Test.Sdk (Version) 16.5.0
NUnit.Console (Version) 3.11.1
Target .NET framework (Version) 3.1
Also, I have tried to disable the ‘code coverage’ option in visual studio 2019, however - I am not able to see it in. Can anyone suggest - where is ‘code coverage’ option available in visual studio 2019.
Charlie's comment is correct - however unfortunately still won't resolve your issue. Your test suite targets .NET Core - which the NUnit Console does not yet support. (Although there is a beta version out with support.)
For now, the best solution is to run with dotnet test, rather than the nunit console. For more details, see the guide here: https://docs.nunit.org/articles/nunit/getting-started/dotnet-core-and-dotnet-standard.html
Version 3.16.1 of the NUnit 3 test adapter is not compatible with version 3.11.1 of the engine, which is used by the console package you installed.
You must either downgrade the console runner to 3.10 or upgrade the adapter to 3.17.
For a detailed explanation see my blog post at http://charliepoole.org/technical/nunit-engine-version-conflicts-in-visual-studio.html
Remove the console runner and run the below command that works
dotnet test [path to your nunit test project solution file]
Ex:
dotnet test D:\MyProject\MobileProject\MobileProject.NUnitTest.csproj
Mac:
dotnet test /Users/MyName/MobileProject/MobileProject.NUnitTest.csproj
https://docs.nunit.org/articles/nunit/getting-started/dotnet-core-and-dotnet-standard.html

Getting NUnit working under Visual Studio Community 2017

I'm new to NUnit and am trying to start using it under Visual Studio Community 2017; I'm having a very difficult time getting up and running.
The actual install of NUnit went well. I followed the procedure (option 1) at the Installation page on the NUnit wiki to add NUnit and NUnit.console, and now have those (and NUnit.ConsoleRunner and a handful of NUnit.Extension.* extensions) in the solution.
The NUnit wiki's .NET Core and .NET Standard page says that next is to install the NUnit template, and here's where I get stuck. It says "Run dotnet new -i NUnit3.DotNetNew.Template to install the NUnit templates." I don't seem to have a dotnet.exe anywhere on my system. Looking at Where is the dotnet command executable located on Windows? it looks like the way to get that is to install Microsoft.EntityFrameworkCore.Tools, which led me to https://www.nuget.org/packages/Microsoft.EntityFrameworkCore.Tools/ . Based on that I tried Install-Package Microsoft.EntityFrameworkCore.Tools -Version 2.0.1 from the Package Manager Console; but that gives me the errors:
PM> Install-Package Microsoft.EntityFrameworkCore.Tools -Version 2.0.1
Install-Package : Could not install package
'Microsoft.EntityFrameworkCore.Tools 2.0.1'. You are trying to install this
package into a project that targets '.NETFramework,Version=v4.5', but the
package does not contain any assembly references or content files that are
compatible with that framework. For more information, contact the package
author.
So I'm really going down a rabbit-hole here, from NUnit3.DotNetNew.Template to to dotnet.exe to Microsoft.EntityFrameworkCore.Tools 2.0.1. Any ideas what to try next?
You were looking in the wrong place.
To get the dotnet.exe (which is not installed by VS2017 out of the box) you need to donwload and install the .NET Core SDK from https://www.microsoft.com/net/download/windows
You need to select the option: .NET Core SDK
.NET Core SDK
Cross-platform .NET implementation. The smallest download to build .NET apps, using command line tools and any editor.
In case this may be of any help to someone: in Visual Studio Community 2017, you can install "NUnit VS Template" from the main menu as follows:
Go to: Tools > Extensions and Updates > Online
Searh for 'nunit'
Click the nunit package you need, and then 'install' on the lateral panel.
You may need to close and reopen VS 2017
Hope it helps

MSBuild fails on Unit Test Project (.NET Core) after NuGet Restore

ISSUE
The Visual Studio Build task in a Visual Studio Team Services build for a solution that contains a default ASP.NET MVC website and a default Unit Test Project is failing to find references. This task runs after a NuGet Restore that should install these references, but even though the NuGet Restore task succeeds, the references are not installed on the server running this build.
Visual Studio Team Services Logs
The error logs have been uploaded to This Github Repository
Attempted Fixes
In an effort to ensure that the packages are properly referenced by the project, all of the NuGet packages were reinstalled from Package Manager using the following command:
PM> Update-Package --reinstall
This only caused MSBuild to not find Microsoft.Net.Compilers.props in both the projects. So in an attempt to correct this, the version of Microsoft.Net.Compilers.props in the project was dropped to version 2.3.2. However, this only brought back the original errors where the MSTest.TestAdapter.props and Microsoft.Net.Compilers.props references could not be found.
Try it with these tasks (works fine for me with the sample solution you shared):
NuGet Tool Installer (Version of NuGet.exe to install: 4.3.0)
NuGet restore (Choose 2.* version)
Visual Studio Build (Visual Studio Version: Latest)
Queue build with the agent that has VS2017 installed.

NUnit fail to build test - No Tests discovered

I am working on selenium web driver project. I was able to built tests in Test Explorer and execute.
At once I am getting following errors when rebuilding the solution.
Unit Adapter 3.2.0.0: Test discovery starting
NUnit VS Adapter 2.0.0.0 discovering tests is started
NUnit Adapter 3.2.0.0: Test discovery starting
NUnit VS Adapter 2.0.0.0 discovering tests is started
Attempt to load assembly with unsupported test framework in C:\..\CustomerTest.exe
NUnit VS Adapter 2.0.0.0 discovering test is finished
Attempt to load assembly with unsupported test framework in C:\..\LoginTest.exe
NUnit VS Adapter 2.0.0.0 discovering test is finished
Exception NUnit.Engine.NUnitEngineException, Exception thrown discovering tests in C:\..\CustomerTest.exe
Cannot run tests in process - a 32 bit process is required.
NUnit Adapter 3.2.0.0: Test discovery complete
Exception NUnit.Engine.NUnitEngineException, Exception thrown discovering tests in C:\..\LoginTest.exe
Cannot run tests in process - a 32 bit process is required.
NUnit Adapter 3.2.0.0: Test discovery complete
========== Discover test finished: 0 found (0:00:02.5558095) ==========
I have changed the default processor architecture in to X64, but issue not resolved.
Please help me to resolve this issue.
Thank you.
I had this problem just today for some odd reason, because I didnt change anything in the meantime and it worked before.
Fixed it by: Project-> [YourProjectName].properties -> Build -> Platform target: "Any CPU" -> Untick "Prefer 32-Bit"
It seems to be the same problem like here: Visual Studio FsUnit test setup - Exception NUnit.Engine.NUnitEngineException So installing Adapter Version 3.0.10 should solve your problem. At least it did for me.
You can follow the issue on github.
I faced the same problem with NUnit 3 Test Adapter (version 3.2.0). I uninstalled it and tried NUnit Test Adapter Version 2.0.0.0. That solved the problem for me.
I used the VS > Tools > Extensions and Updates to install/uninstall the adapter.
My VS project is set to build for Platform x86 and I was using VS Ultimate 2013 Update 5.
I had the same problem with my .NET Core 2.0 project with NUnit 3.9 in Visual Studio 2017 and was stuck with this for quite some time. None of the solutions suggested in other related questions worked.
Then I figured out from this link that a class library with target .NET Standard does not work. The test project has to target .NET Core. Also, Microsoft.NET.Test.Sdk NuGet is required.
So, the steps are
Make sure that the test project targets .NET Core
Install latest NUnit NuGet (I used 3.9)
Install corresponding NUnitAdapter NuGet (I used NUnit3Adapter)
Install Microsoft.NET.Test.Sdk NuGet
Re-build and your tests will appear in Test Explorer in Visual Studio.

Using NUnit from Visual Studio to MonoDevelop

I get this error when I try to run unit tests on a solution originally from Visual Studio: RemotingException: Unix transport error.
I originally let MonoDevelop grab it's own NuGet packages including NUnit 2.6.4, NUnit.Runners 2.6.4, and NUnitTestAdapter 2.0.0. I then tried using the 2.6.3 references included with MonoDevelop and getting rid of NuGet packages including NUnitTestAdapter 2.0.0. I also tried using NUnit 3.0.1. All of these resulted in the same errors. How can I get NUnit to work with this solution?
The project can be found at: https://github.com/ParagonTruss/GeometryClassLibrary
It turns out that when I reinstalled the NUnit Visual Studio Test Adapter in Visual Studio it would change <Private>True</Private> in the .csproj file to <Private>False</Private> and then worked fine in MonoDevelop.

Categories

Resources