I have a solution file which contains two project, one is main project and the other is an unit test project.
I had them install both NuGet Package NUnit and NUNit3TestAdapter
However, I still cannot create nunit unit test near the function I want to test by the mouse right click event
As you can see, only MSTestV2 framework is detected.
My question is: How can I use the NUnit framework to create unit tests in Visual Studio 2022 Community?
The TestGenerator extension has not been released for x64 which VS2022 yet.
What you do is to use command line tools:
Create a new folder for your test projects.
The run :
dotnet new nunit
This will create a new NUnit test project.
Add this project to your solution and add a project reference from there test project to your other project "to be tested", and off you go :-)
Related
I have a useful extension for Xunit which I use through various .NET 3.1 projects. I want to build a NuGet package to easily distribute it.
But when I add a Xunit dependency to my Visual Studio project it is immediately marked as Unit Test project and stops generating .nupkg file (I have "Generate NuGet package on build" checked in the project settings).
Can anyone help me?
I ended up deleting unnecessary dependencies like "Microsoft.NET.Test.Sdk" after that my project stopped being a unit test project. Then I switched Xunit dependency to xunit.extensibility.core which is supposed to be used especially for extensions.
Finally, Visual Studion successfully generated .nupkg file on build
For some reason Visual Studio 2017 does not recognize unit tests in Universal Windows Unit Test App projects.
Steps to reproduce:
Create a new Unit Test App (Universal Windows) in VS 2017
Add Assert.IsTrue(true); to the unit test created
Click on Test -> Run -> All Tests
Expected: unit test discovered and run successfully.
Actual: no tests found.
Output Tests produces absolutely no output.
Comment if there is a log file containing some more info and I'll add it.
EDIT: So it turns out they don't work in 2015 either. I have ReSharper in 2015 which is able to run them. But why can't the VS runner run them?
By sheer dumb luck (or just desperation), I went to my Test project and Deployed it (right click on project-> Deploy). That made the tests appear and now they run.
This now works in Visual Studio 2017 (version 15.4.5 currently).
After building the solution, the tests appear right away. Deploying the test project may have also worked in the older versions.
I have a pretty simple question: What kind of project should I create for Integration Tests in Visual Studio? The only proposed project type under Test tab in Visual C# is Unit Test Project, but it's not integration test, so I'm not sure
This is what I read, but couldn't find an answer :
Integration Testing In Visual Studio With Different Project Types
How do you separate unit tests from integration tests in Visual Studio?
Thanks!
Use the unit test project template. You will create your integration tests in there.
The unit test project is just a template that provisions the necessary dependencies. You could just as easily create an empty project and manually add what it needed.
I am beginner for xunit testing.
My colleague has installed xunit from nuget packages of visual studio 2013 update 3. Then he did the unit testing and checked in everything in SVN.
When I took the updated code from SVN, it shows me everything fine.
But, when I am running the individual test case, test case is not running.
Also, Test explorer is not showing any test from test project.
Please let me know the solution.
Thanks.
I was trying for installaing xunit runner from nuget packages so test explorer was not showing the unit test cases. I took the older version of xunit runner and installed. It works for me!
Thanks!
If you are using latest xunit.runner.visualstudio 2.0+ NuGet package then try to delete folder like xunit.runner.visualstudio.0.99.9-build1021 with obsolete runner from your NuGet packages folder if such exists.
I can see both test projects from the NUnit Gui (loaded separately) but I can not see both projects from the Visual Studio Test View. The Test View only shows the first/original project. Hitting reload doesn't do anything. How do I get the Test View to display the second/later project? It should show both at the same time/same view, yes?
If I can only see one project's test in the Test View by design, how do I get the Test View to change projects?
Details:
I created the second project by hand ie not "create a test" as a project library with the nunit.framework.dll referenced. I checked the assembly files of the two projects as well as the properties and they look the same.
I'm on VS 2010 Professional using NUnit 2.6.0.12051 with "Visual NUnit 2010" version 1.2.4 extension installed.
I have one NUnit test project that is working both in VS Test View and NUnit Gui. I added a second project with a [TestFixture] class and a [Test] method. All projects build sucessfully. Both tests refer to the nunit.framework.dll in a parent directory to both.
There is a tag in the project file describing a project as a test project.
In the PropertyGroup section of the csprj file, add this:
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
See more details here:
http://www.kindblad.com/2010/08/07/how-to-change-an-existing-visual-studio-project-into-a-test-project
There are many problems that can cause this. Here's what mine was:
I had 2 NUnit test projects.
"Test Explorer" -> "Run All" would only find tests from one project.
Explicitly right clicking on one of the tests that wasn't found and clicking "Run Test" resulted in "No tests found." in the Output window.
All projects on all configurations were set to Any CPU, but it didn't matter if X86 was chosen for everything either.
The problem was that my Visual Studio (2015, FWIW) was using Test Adapter 2.x, and one of my projects had pulled NUnit 3.0 using NuGet. Test Adapter 2.x doesn't run NUnit 3 tests, so my NUnit 3 test project was being ignored.
To solve the problem:
Uninstall all NUnit Test Adapters (from Visual Studio -> Tools -> Extensions and Updates and from each project's NuGet Package Manager window).
Update all test projects to NUnit 3.0 using each project's NuGet Package Manager Window.
Install the NUnit3 Test Adapter from Visual Studio -> Tools -> Extensions and Updates
Notes:
If you need to stick to NUnit 2, then just install the appropriate Test Adapter. The important thing is consistency.
If you were using test adapters installed by NuGet before, but switched to a Visual Studio Extension, then you may have problems loading resources/files from path strings. See this answer to solve that issue.