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.
Related
I wanted to setup a quick test project to test a few things in my solution. The solution has a few projects in it some class libraries, windows forms projects, etc. I just wanted to test something and now this is turning into a major pain and taking over an hour, and I don't understand why.
I add a new test project to the solution (only seems to have .Xunit or MSTest .Net core, does that matter?) and then add the appropriate project references. Running the test project from scratch works fine it's only when I set it up to run with my other projects (in the same solution) references does it get confused referencing my projects.
This issue seems to be more related to Visual Studio and test projects than MSTest or Xunit, I tried both test frameworks and get the same type of issue it can't find tests.
It's basically the same in both frameworks just can't find tests even though annotations are correct:
[12/1/21 6:37:52 PM Warning] No test is available in C:\Users\main\Tests\bin\x86\Debug\netcoreapp2.1\CadWrapperTests.dll. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again.
[12/1/21 6:37:52 PM Informational] ========== Discover test finished: 0 found (0:00:03.2242021) ==========
[12/1/21 6:38:22 PM Informational] Executing test method 'Tests.CheckDrawingIsClosed'
[12/1/21 6:38:23 PM Error] System.InvalidOperationException: The following TestContainer was not found 'C:\Users\main\Tests\bin\Debug\netcoreapp2.1\CadWrapperTests.dll'
The projects are all using .NetFramework and x86 architecture, but the test project only lets me choose .Net Core and when I add new .NetCore test projects are the only options, is that the issue?
It won't find tests and the errors aren't useful but it shouldn't be this difficult to add a test project and write some tests..
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
In my VS2017 solution I have several unit test projects.
In on of them my xUnit tests do not get discovered by mstest and therefore are not run.
I do get the warning:
Warning: [xUnit.net 00:00:00.7641189] Skipping: Testing.UnitTests (could not find dependent assembly 'Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0')
But Microsoft.VisualStudio.QualityTools.UnitTestFramework is referenced in the project in exactly that version.
I have multiple unit testing projects. Many of them contain xUnit tests as well, but they get found and executed without any problems.
All projects containing xUnit tests have the same xUnit nuget packages assigned, especially xunit.runner.visualstudio
I am also using NCrunch and NCrunch has no problem discovering and execution the xUnit tests in question.
What could possibly be the reason to my problems?
Further Findings:
After upgrading Microsoft.VisualStudio.QualityTools.UnitTestingFramework to version 10.1.0.0, the xUnit tests were found but then I suddenly had 438 from 2447 failing. Those failing tests -mostly not xUnit - were previously working fine.
After shutting down an restarting visual studio the UnitTeestingFramework was automatically reset to version 10.0.0
opening the Reference Manager (Add References) all the project references are shown by selected checkboxes except of Microsoft.VisualStudio.QualityTools.UnitTestingFramework which only shows up if I previously add e.g. "Quality" to the search box, but then I see Microsoft.VisualStudio.QualityTools.UnitTestingFramework three times. One checked (version 10.0.0.0) an other one with same version, but different path and one with version 10.1.0.0
All together looks quite odd to me...
I had this issue but am not sure if this is exactly the same as yours. I saw an error in the output/tests window which stated it couldn't restore package xunit.runner.utility 2.2.0
After manually adding this in in package manager console like so:
install-package xunit.runner.utility -v 2.2.0
It started working again
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.
I spent far too much time trying to run a basic NUnit test on a Microsoft Store app. I installed NUnit v3.0.1 and NUnit3TestAdapter on VS2015 Pro but I get the following which confirms that the test is not discovered:
------ Discover test started ------
NUnit Adapter 3.0.8.0 discovering tests is started
Exception NUnit.Engine.NUnitEngineException, Exception thrown discovering tests in <project exe file>
The NUnit 3.0 driver does not support the portable version of NUnit. Use a platform specific runner.
NUnit Adapter 3.0.8.0 discovering test is finished
========== Discover test finished: 0 found (0:00:01.0639991) ==========
The NUnit.Engine.NUnitEngineException error referred to is not helpful because there is no way of exploring where the exception is in my program. The test is a single method with one Assert statement just to test if the setup works so there is nothing complicated. I also don't understand what a "platform specific runner" is. I installed both NUnit and NUnit3TestAdapter thru NuGet Package Manager and I presume installations for relevant platform and version are carried out.
I even tried out installing "NUnit Templates for Visual Studio". This allowed me to create an NUnit project, and interestingly the test within NUnit project is discovered and run. But the downside is that I cannot reference my UWP app project from the working NUnit project, I think because the NUnit project only supports .Net frameworks (up to 4.6.1) not Windows 10 platforms.
I have used NUnit before for non UWP applications without much trouble. Am I missing something or NUnit as yet doesn't support UWP apps?
At the moment you can only test DNX projects with XUnit.
Here is a nice starting point for that.
From the official Asp.Net 5 documentation (which uses the same infrastructure as UWP):
For example, to work with the xUnit test framework, you would
configure the dependencies as follows: [example project.json I dont
want to copy]
As other test frameworks release support for DNX, we
will link to them here.
Since there are no other frameworks linked in the documentation, I assume that there are none that support DNX projects at the moment.
Since this question was originally posted NUnit has developed it's support for testing UWP/Xamarin apps. Check out the nunit.xamarin runners.
Essentially, your tests should be created in either a portable library, or a shared project. This can then be referenced by a UWP project runner, which can be run on the emulator.
If you take the shared project approach, you can also reference this through an .NET 4.5 project, which will allow your tests to integrate with the NUnit VS adapter, and show up in VS. Portable libraries can not yet be run with this runner, however that's in the pipeline.