xUnit Tests not running after building - c#

I'm trying to run unit tests in VisualStudio 2013. My tests are discovered under the Test Explorer but after running the tests, the project builds and stops. All my tests are then categorised under "Not Run".
I'm not getting any error messages or exceptions.

Thanks Jeroen Vannel & gunr2171.
I fixed it by installing xunit.runner to the test project from the NuGet Manager instead of running the installation of the xunit.runner Visual Studio Extension file I downloaded previously.

Related

The tests are not shown in specflow + nunit3 with Visual Studio 2017

I'm starting with BDD and spec-flow in C# and Visual Studio. I was following a tutorial at https://www.toolsqa.com/specflow/set-up-specflow/ to set up a project but I cannot be shown the tests in visual studio 2017 to run.
The steps I take are the following:
I create a project as a class library in the .NET Framework
I add spec-flow to the project
I add the NuGet Nunit test adapter and Nunit Framework (version3)
I generate the .feature file
I generate the file steps associated with the feature.
I compile the solution but in the test window I don't see any tests that run
I searched for several tutorials but I can't find what my mistake is or what I'm missing.
Can anyone help me?
Install the "SpecFlow.Tools.MsBuild.Generation" nuget package and rebuild the solution. That should get you going.
We have a "Getting started" guide on the website: https://specflow.org/getting-started/
Also we have some examples here: https://github.com/techtalk/SpecFlow-Examples
You could compare your project with the example if you missed something.
I had the same issue . And when I upgraded my specflow to 3.0.213 , feature.cs and tests were not generated in test explorer. Then I used this MSBUild example with latest specflow to generate feature.cs and tests in test explorer. It uses MSTest as test runner and not Nunit. If test runner doesn't matter to you, use this example. I am running it on visual studio 2019
Had the same issue,
Besides adding the nuget package
SpecFlow.Tools.MsBuild.Generation
as Meza mentioned.
The testes did not appear in the Test Explorer before i added
SpecFlow.NUnit.Runners
besides already having
SpecFlow
SpecFlow.NUnit
NUnit
NUnit3TestAdapter
and the Visual Specflow extension
(VS2019, Specflow 3.1.67)
As an update these were the nuget packages I had in place to finally get an example working, using selenium running under NUnit. (It may be useful to someone)
It is better for you to use visual studio 2015 to do the same things that you want.

NUnit on Visual Studio 2017 (Enterprise): Test Runner only works as Extension, not Solution NuGet package?

My problem is very similar to NUnit Unit tests not showing in Test Explorer with Test Adapter installed, in that I couldn't get the NUnit tests to appear in the Test Explorer (despite multiple rebuilds, setting the Test architecture to x64, etc). I rebuilt and rebuilt, and despite having NUnit 3 and the NUnit 3 Test Runner installed into my Solution (via Tools -> NuGet Package Manager -> Manage NuGet Packages For Solution...) I couldn't get the tests to appear.
On the advice of another response to the above question, I installed the NUnit 3 Test Runner as an Extension (which modified all of Visual Studio, not just my project).
After the extension is installed (and I do Yet Another Rebuild :) ) all my tests are listed in the Test Explorer.
Question: Why do are the tests shown in the Test Explorer for the Visual Studio-wide NUnit 3 Test Runner Extension, but NOT in the Solution-specific NUnit 3 Test Runner NuGet package?
What's even weirder is that the exact same project, with the per-Solution NuGet packages for NUnit, work just fine on my personal computer (WITHOUT the NUnit Extensions installed), using Visual Studio 2017 Community edition. It's only when I .ZIP the project and email it to another computer (which runs Visual Studio 2017 Enterprise) where I have this problem.
I'd prefer to install NUnit into the solution so that I can hand out copies to my students and have the project be completely self-contained.
Does anyone have any advice on how to further dig into the problem with the per-Solution NuGet package? I'm kinda stymied since the only obvious thing to try is "rebuild it again and see if that helps" :), so any thoughts on stuff to try / strategies to use would be great.
At this point it looks like the Virtual Machine that I'm running the tests in thinks that the project is being run from a network drive. .Net has different rules for running code remotely and by default doesn't want to execute remote code (which seems reasonable :) ).
It's worth pointing out that NUnit should (and does!) work just fine in a VM where the project is saved onto a virtual disk - it's just the 'network drive'/file share that's causing the problem.

Reporting tool for Nunit 3 and Selenium C#

I'm using Selenium with C# to create my automated tests. Now i have to use some sort of reporting tools to save the test cases whether they passed,failed...etc.
I've seen a lot of tools like Allure, and Jenkins. But they require an XML file. and i can't find it when i run my tests using Visual 2013. Why is that ?
how to obtain these XML files in details if i'm missing something ?
Is there any way i could achieve this with minimum effort ?
EDIT:
How can i run my tests using Nunit console runner ? where can i find it? i downloaded the .zip for nunit but i couldn't find the runner?
The NUnit Visual Studio Adapter does not currently produce XML results, although there is an issue on GitHub to add the ability. Your best bet is to run your tests using the NUnit Console runner when you want to create reports. It always produces an XML result file.
You can install the NUnit Console by adding the NUnit.Console NuGet package to your test project. The console will be in a directory like packages\NUnit.ConsoleRunner.3.4.0\tools in your solution root.
Another option is to install the MSI for the console runner. It will then be under C:\Program Files (x86)\NUnit.org\nunit-console
For creating reports, ReportUnit creates excellent HTML reports from your test results.
To run the tests, I would recommend setting up a simple command line build that builds your solution, runs the tests and then produces the report. For day to day development, just running your tests in Visual Studio or on the command line will likely be enough. Most developers find the Visual Studio Test Explorer Window to be a poor UI, but usable for seeing passed and failed tests and running/debugging them.
If you want to setup a command line build, one good tool is Cake Build. It will take a bit of time to setup, but it is an excellent way to run your build tasks as your project gets larger.
NUnit testing can be run with the nunit-console.exe application which is installed with nunit under {Project_root}/lib/nunit/nunit-console.exe. It downloads with NuGet when NUnit installs.
It can be passed a list of testing binaries, or testing project files, or an nunit project (listing multiple if needed).
{PathToProject}\lib\nunit\nunit-console.exe {PathToTestDll}\Project1.Tests.dll {PathToTestDll}\Project2.Tests.dll /xml=nunit-result.xml
or create an NUnit Project with the NUnit Project Editor if you want to group all your test projects into a single config file.
{PathToProject}\lib\nunit\nunit-console.exe {PathToNUnitProject}\Project.Tests.nunit /xml=nunit-result.xml
Allure doesn't require xml. At lease now :)
https://github.com/unickq/allure-nunit
You just use [AllureNUnit] attribure

NUnit Test Adapter is showing duplicate failed tests

I am using NUnit Framework 2.6.4 and NUnit Test Adapter 2.0.0 (which seems to support up to 2.6.4). I am running Visual Studio 2015.
I have noticed in the Test Explorer Window that when tests fail, they show up as duplicates 3-4 times in a row the failed section. Has anyone else seen this? Is this a setting (is the test being run more than once?) or could this potentially be a bug?
I have not noticed any of my passing tests being duplicated.
My end goal is to clean it up. I only want to see the failed test once.
Check to see if you have installed both the nuget package and the vsix extension. With VS2015, if you have both installed, both are used. Prior to 2015, the extension was used in preference, which caused different kinds of problems. :-)

VS 2010 and MBUnit how to run just one test

I have Gallio/MbUnit installed and am using VS 2010 RC and I want to be able to run a single unit test or just all unit tests inside of a TestFixture and not all the tests in the entire project everytime I debug. How do you do this in VS 2010?
Install testdriven.net, there is a free personal version
http://www.testdriven.net/
As Simon said, TD.Net is just working well.
If you work with VS2010 Premium or Ultimate, you may also use the built-in test run feature of VS2010. It should find and run your MbUnit tests as well (if the Gallio add-in was installed)
You may also run your tests by using Resharper 5, but it seems that the latest beta of Resharper 5 has broken the Gallio test driver. It should be fixed soon however.
Apart from the VS2010 IDE, you may also run your tests with Echo (a powerful console application located in the bin folder of the Gallio installation directory), Icarus (Winform application with a nice UI; same location), or from PowerShell (by using the Run-Gallio snap-in). You can also invoke the test runner from one of the numerous extensions of Gallio for MSBuild, NAnt, TeamCity, etc.
I didn't see it earlier but VS 2010 has a Test List Editor which allows me to add the specific test to a a list and run it from there so that only the one test is run. I know that TD.Net probably has a right click/run test option for a test method but I didn't want to buy it and install yet another tool.
Another alternative, how we do it is select the specification inside visual studio, press F5, and it runs the specification via a Rake task.
Example:
class DiffuserObserverSpecification
: AutoMockSpecification<DiffuserObserver, IDiffuserObserver>
class When_diffuser_observer_is_created : DiffuserObserverSpecification
class When_diffuser_observer_has_injected_diffuser_change
: DiffuserObserverSpecification
So to execute the behaviour expectations of all DiffuserObserverSpecification, we select the DiffuserObserverSpecification and press F5.
And to execute just the behaviour for When_diffuser_observer_is_created, select that and press F5.
After one month you forget what I debugger looks like.

Categories

Resources