SpecFlow not listing NUnit with VS2013 - visual-studio-2013

I had tried all the way on the web.
But it still not listing NUnit in Tools -> Options -> SpecFlow test runner.
I install "NUnit Test Adapte" already.
I tried to attach NUnit but I can't find "NUnit" in available process.
Is I having wrong way to install NUnit? I downloaded the NUnit.zip and decompressed it in Program files.Did it need more steps to install it?And I also install the NUnit package in VS2013.
What's wrong did I done?Or what isn't done yet?
Please help me.

As the comment said, there are too many things that could be wrong. Here are a few suggestions you could try.
Verify feature files are being converted into tests.
How to Verify: In VS solution explorer, expand the feature file and you should see a feature.cs file.
Solution to fix: install the SpecFlow solution
Verify the test is a nunit test and not mstest
How to Verify: Open the feature.cs file and verify you see NUnit somewhere on that page and your scenario (no spaces) should have [TestAttribute] above it.
Solution to fix: Add nunit reference to the project & in the project's app.config Add NUnit as the provider
Verify NUnit Test Adapter is installed
How to Verify: Write a simple nunit test & see if it shows up in the test explorer window.
Solution to fix: Install it or you can always install SpecRun as an alternative. VS Test explorer should show your tests and they can be run from there.
Verify all your tests are mapped
How to Verify: Your tests should be black except where you have variables. Hitting F12 should go to definition.
Solution to fix: There can be a caching issue but for the most part, verify the regex is correct and make sure the step definition is visible to the feature file. That means it's either in the same project or is included in the app.config as a known step assembly.

Related

Why will Visual Studio 2019 will not run my unit tests?

I am seeing some very strange behavior for NUnit tests in VS2019, where the same solution works fine in VS2017. There are several NUnit test projects in my soultion.
In VS2017 with the NUnit Runner extension installed, I can see all of my tests in the Test Explorer window and the "run all" button will work and run all tests. Some developers in my organization use Resharper instead of the NUnit extension and this works too.
I have stopped using Resharper because as VS introduces more features, Resharper has made it so slow that VS is unusable.
In VS2019 the Test Explorer window will show all of my unit tests (even without the NUnit extension installed). If I click "run all" it will not run any tests and the Output window will say 0 tests discovered. Coworkers have said that Resharper will run all tests without issue. If I right click a single test project and run just those tests, some projects will run tests, but not all.
For some projects I have tried installing the NUnit3TestAdapater nuget package and this will let VS2019 run that project's test if only that project is selected. This does not work for all projects and it still does not work for "run all".
Does anyone know what might be causing this and what could fix it? I have updated to the latest version of NUnit (3.12) and latest TestAdapter (3.16) for all of these projects.
This has been a real pain for about a year, because I need to keep VS2017 and 2019 both installed, and I need to train new developers on how to work around this weird issue.
I stumbled upon the same problem. It seems to me that I have to install more and more with each release.
In my case (Visual Studio 2019 community edition, version 16.6.1), I now also had to obtain the Microsoft.NET.Test.Sdk via NuGet.
So in the end, I have installed three packages in my test project:
NUnit (3.12.0)
NUnit3TestAdapter (3.17.0)
Microsoft.NET.Test.Sdk (16.7.1)
Turning the automated test discovery on or off did not change anything for me though.
Hope this helps anyone.
The solution turned out to be a combination of two things.
On the top menu, navigating to Test > Options and disabling "Discover tests in real time from C# and Visual Basic .NET source files". This option appears to be incompatible with parameterized tests. The problem is that parameterized tests do not "exist" in source code but are generated by the test adapter at runtime. This also fixed an issue I've seen where the "base" test of the parameterized test shows up in the Test Explorer as a not-run test, even though only the specific test cases are real tests. (In my opinion, this should not be enabled by default because parameterized tests are extremely useful, whereas seeing new tests in the Test Explorer without compiling is a trivial convenience since you must compile to run them anyway.)
Using the NuGet package for the test adapter instead of using the VSIX extension. It seems that for this piece, all that is required is that at least one project in your solution references this. If at least one project references it, all test projects can be run. (This makes sense to me, as it is more compatible with build tools outside of Visual Studio.)
Hooray for breaking changes!
I had the same issue and solved by checking the logging.
In Tools->Options->Test->General setting the Logging Level to Diagnostic. This will produce additional output in the Tests Output Pane of the output window.
In my case the issue was linked to missing version of ".NET Core 3.1 Desktop Runtime"
You can download the last version in https://dotnet.microsoft.com/download/dotnet/thank-you/runtime-desktop-3.1.14-windows-x86-installer
In my case I had to install also the Microsoft.NET.Test.Sdk nuget pack.
After none of the above worked for me.
I just installed xunit.runner.visualstudio nuget and everything is working fine now.

Installing test runner on Visual Studio without NuGet

I recently installed XUnit and the XUnit VS runner (i.e. xunit.runner.visualstudio) on Visual Studio following the documentation. The installation process uses NuGet and on completion I can successfully see all tests in the MS Test Explorer.
However, if I start a new solution and reference all the required XUnit dll's, i.e., I want to use XUnit without using NuGet to install it, the tests never show up in MS Test Explorer (no problems seeing them in the ReSharper test explorer).
I think this has something to do with the XUnit test adapter that Visual Studio uses to find XUnit tests. It appears that NuGet somehow instructs Visual Studio to create the VisualStudioTestExplorerExtensions folder on each build putting the necessary XUnit test adapter dll's (e.g.xunit.runner.visualstudio.testadapter.dll) in that folder. The MS Test Explorer then uses this test adapter to find XUnit test (see SO Question).
When I attempt to use XUnit without NuGet, the VisualStudioTestExplorerExtensions folder never gets created on build. Adding the folder manually with all XUnit dll's in it also doesn't work. It's almost as if i need to instruct Visual Studio to look in that folder, but I can't see any obvious way of doing that.
How do I use/install XUnit without using NuGet? Or, how do I get VS to look in the `VisualStudioTestExplorerExtensions' when looking for tests?
If you want to install a test runner manually, copy all the necessary dlls to:
C:\Program Files (x86)\Microsoft Visual Studio {version}\Common7\IDE\CommonExtensions\Microsoft\TestWindow\Extensions
Replacing {version} with the appropriate number.
The drawback here is that this is machine wide (maybe desirable in your case), and that you can't quite as easily replicate this setup on a build server. You also will probably have to restart VS whenever you make changes to these files.

Using XUnit with Visual Studio Online

I've setup my build as below using the build definition. I'm using XUnit and locally my tests are discovered and run. I've tested the glob **\*spec*.dll and it finds all my test dlls and the build log shows that those dlls are in fact built.
However in the build log I get
Run VS Test Runner
No test found. Make sure that installed test
discoverers & executors, platform & framework
version settings are appropriate and try again.
Which seems to suggest it is trying to use the MSTest test runner instead of the XUnit test runner. How do I tell the build for visual studio online to use the XUnit test runner and discoverer?
This might be out of date now, but this is how I have it setup and working - downvote and let me know if it's wrong and I'll delete this. I got it from a blog post/MSDN page, but I can't locate it any more.
First you need to create a TFVC Team Project (doesn't matter if you don't use it again).
Into $/MyTFVC/BuildProcessTemplate/CustomActivities/
Checking the following files from xunit.net:
Now in VS, click the BUILD, Manage Build Controllers... option. Select the "Hosted Build Controller (Hosted)" and click "Properties...".
Enter the path where you checked in the DLL's into the "Version control path to custom assemblies" field:
You should be good to go.

Unit Tests are failing on a "Build failed" in the Session window with no message providing a reason for failure in Visual Studios 2010

I had recently installed VS 2010 on my local machine, and cannot seem to get Resharper 5.1 and the unit tests to work correctly.
Whenever I try and run Unit tests I get a "Build failed" with the test icon remaining gray, but with no info in the output window and no discernible reason why.
The Unit Tests run perfectly fine when doing a nant build.
Running a previous branch of the code on VS 2008 does not have this same issue as a result.
Any ideas?
Check your build configuration. If you're using a build configuration that is set to not build your test projects (like your release configuration) then the Resharper test runner will fail this way. The output looks like a perfectly successful build but if you inspect the output you'll find your tests are not in it.
Another symptom of this issue is if you set the test runner to not build as suggested above, next time you attempt to run the test it will be crossed out in the test runner.
Build configurations can be found in Build->Configuration Manager in Visual Studio.
If you change the build settings to 'never build' in the unit test sessions window, it works ok (providing you pre-build the dll using visual studio). It appears to be a Resharper bug.
In my case this did solve the issue:
http://www.shirmanov.com/2011/07/project-has-not-been-built-resharper.html
I had the UnitTests set "to not build" in my solution configuration.
The above mentioned article shows this very detailed.
In my case I was missing a DLL that was not added to the project. I added it, cleaned and build and everything was okay.
Verify in Visual Studio Configuration Manager that your test projects are marked to be build.

nunit locking dll

I have been using nunit with visual studio 2010 on a windows 7 64-bit pc.
I am able to open the nunit gui and run my unit tests. If I then change one of the unit tests and try to rebuild, I am getting a file locking error as follows -
Error 1 Unable to copy file "obj\Debug\myProject.Tests.dll" to
"bin\Debug\myProject.Tests.dll". The process cannot access the file
'bin\Debug\myProject.Tests.dll' because it is being used by another
process. myProject.Tests
I have used process explorer to verify that it is the nunit-agent.exe that is locking the dll.
I have noticed via tools > test assemblies that the nunit.exe is running under clr version Net 2.0 and nunit-agent.exe is running under clr version Net 4.0. could that have something to do with the problem? If so, how can I fix it? If not, does anyone have any idea what else may be going on?
Thanks for any thoughts.
I think this has to do with the placement of my test project. Initially, I was putting the nunit test project in a seperate directory from my dll files. I was thinking that I would keep all of my test projects in one centralized location.
I them moved my test project into the same location as my test dlls under my visual studio projects. After that, it seems to be working correctly.
I think this has to do the shadow copy. I read in the nunit group on google that the .net framework will only shadow copy assemblies in the application base or it's subdirectories.
This led me to try creating the nunit test project within my application base and that seemed to work.
Hope that makes sense.
Thanks
I also faced the exact issue, however czuroski's answer did not work for me (although I think that we are in effect talking about the same thing).
What did work for me was to ensure that in NUnit I set the Project Path and Project Base were pointing to the same root application folder under Project -> Edit. I re-saved my existing Nunit project to the same directory as my VS sln file.
Another thing to check is to make sure that Shadow Copy is enabled in Nunit -> Tools -> Settings -> TestLoader -> Advanced -> Enable Shadow Copy
try this, Tools > Settings > Test Loader > Assembly Isolation > Default Process Model > Run tests in a separate process per Assembly.

Resources