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
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'm attempting to write tests with NUnit3 as part of some tech-debt migrations. I created a new project within an existing solution. Using nuget I added NUnit and NUnit.Console as per the instructions on github. (I also added the NUnit 3 Test Adapter extension to Visual Studio 2015, but I'm fairly sure that has no bearing on my current situation).
After adding the nuget packages I attempted to import the TestFixture attribute, however, visual studio isn't recognizing the NUnit.Framework namespace and I can't import anything.
The only thing I could thing to fix it was to add the reference manually. There too I was blocked by NUnit not being available.
I'm somewhat at a loss as to how to move forward. How do I proceed and fix the missing reference?
Update: The project I created was of type Unit Test Project, however I've gone ahead and create a Console Application and Class Library. I attempted to add NUnit via nuget to each of them and all of them have had the same result.
Update: Other nuget dependencies seem to install correctly with no discernable difference.
This is only a pseudo solution, as I don't know what the actual issue is. If anyone else comes across a better fix than my work-around I'll be glad to select it if it works for me down the line.
At the time of this writing, the latest version is 3.4.1. I forced nuget to downgrade to 3.4.0 for both the packages NUnit and NUnit.Console and violĂ the namespace is available as you'd expect any nuget package.
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.
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.
I am currently trying to use TestDriven.Net with MSpec. I installed TestDriven.Net and then imported MSpec from Nuget into my class library. When I try to run my tests I get the following output.
The target type doesn't contain tests from a known test framework or a
'Main' method.
I have also copied the Machine.Specifications.dll.tdnet and Machine.Specifications.TDNetRunner.dll in the Debug folder of my solution where all the dlls are deployed but still I see no change.
Am I missing something?
Try running the TestDriven.Net batch file installer first. It's shipped with the Nuget package. You can find it under
\packages\Machine.Specifications.0.8.3\tools\InstallTDNetRunner.bat