Namespace and Fixture is Empty in Visual NUnit - nunit

I am new to NUnit. When I am run the test cases using NUnit GUI its working perfectly, but when I use Visual NUnit from View->Other Windows->Visual NUnit, only the project is loaded. The Namespace and the Fixture in it are empty. Here is a screenshot:

I had the same issue and manage to resolve it as follows:
Set the NUnit test project as my startup project.
Build the entire solution.
Click the "Run" button without entering a Namespace or Fixture field.
The fields should now become populated.
Hit "Run" again to kick all the tests off.

Related

How can I convince eclipse/JUnit4 to find all my tests, in a gradle/eclipse project?

Background
JUnit 4 test runner, within Eclipse 4.11.
I have an eclipse project that was imported from a build.gradle file. This project has several different source paths, each with their own test path.
main/java, test/java, foo/java, fooTest/java, fooTest/resource, and so on.
Problem
When I run a "whole project" JUnit configuration (debug, run, code coverage, whatever), all it finds are the tests within "test/java". I have successfully added new test classes and new #Test methods within this folder.
Tests from any other source path are ignored when I try to "Run all tests in the selected project, package, or source folder". Furthermore, selecting the specific source folder 'fooTest/java' errors out with the message "No tests found with test runner 'Junit 4'". However, when I use the "Run a single test" option with a specific test class, it finds all its test methods just fine. I can specify a particular method and the test runs just fine.
Stuff that didn't work
I tried changing the output directories of my non-main test source paths to write to the same folder as my working test source path. No joy.
I tried various settings of Eclipse's "Contains test sources" flag for my different test source paths. On or off, the behavior is the same across all my test source paths. /test/java is always found, fooTest/java is always missed. No, I haven't tried all 16 permutations of the flag across my 4 different test source paths.
I tried ripping out all the gradle-related stuff from the .project and .classpath. No change in behavior. Dammit... got my hopes up.
I tried changing the order of the <classpathentry/> in the .classpath project file. When I moved test/java such that it was no longer the first test path, I once again got the "no tests found" error, just like when I aimed the junit configuration "run all tests in the selected project, package, or source folder" at one of my other test source folders. Putting it back restored the original behavior.
Does anyone have further suggestions I could try to make my remaining tests run without individual configurations for every test class that I must manually run one at a time?
I switched to the JUnit 5 test runner, and it picked up on everything just fine. It's vintage package was able to find all my JUnit 4 tests, and I've since modified several tests to use the newfangled annotations and Assertions in JUnit 5.
Perhaps this was a known bug/limitation in the JUnit 4 runner? Ah well. It works now.

How to run NUnit tests from inside Visual Studio?

I have downloaded the source for NHiberate 4.0.4 and want to run some of the unit tests. Not sure how to go about doing this. I played around with NUnit several years ago and seem to remember there was a addin for visual studio but couldn't find it. Is there a way to run the NUnit tests from within Visual Studio, similar to the way JUnit works in eclipse?
It's an old question but still deserves a step-by-step, how-to answer with reference to the latest versions of VS (2019) and NUnit (4.0) since NUnit tests won't run in VS 2019 out-of-the-box.
Here's how to set it up:
Install the NUnit 3 Test Adapter extension to VS by selecting Extensions > Manage Extensions from the main menu. Restart VS to complete the installation.
Add a Class Library project to your solution. Right click on the project and select Manage NuGet Packages menu option. Browse for NUnit and install it.
Add a public, non-static class to the project to host your tests. Mark the class with the [TestFixture] attribute. Also, don't forget to add the required using NUnit.Framework directive.
Add a public method to the class and mark it with the [Test] attribute. Repeat with as many methods as necessary.
Build the project and then select Test > Run All Tests from VS main menu. The Test Explorer will pop up and show you the progress and outcomes.
If you are using Visual Studio 2012 or higher, then yes, you can run NUnit tests directly from Visual Studio. I think NUnit Test Adapter
may be what you need. For VS 2013 and higher this may not be necessary - if NUnit Framework is installed and the project references it, anything declared as [TestFixture]/[Test] has a Click to Run icon on the left.
Hope this helps!

Cannot run tests using NUnit Test Runner from SpecFlow feature files

Using the current version of ReSharper (9.1) and NUnit (2.6.4), whenever I right click a feature or step in a feature file and click ReSharper's "Run Unit Tests" it throws an error and says no unit tests found.
I've found if I use the built in MSTest or if use SpecRunner, it works fine, but I lose the features of NUnit.
I can run NUnit tests fine normally, and confirmed that the proper version of NUnit is listed in my SpecFlow config, and ReSharper settings, and everything appears to line up.

ScalaTest runnning only a single test in a suite

While developing a test suite for a class, I've began running into situations where ScalaTest would only run a single test, or exclude some of them.
Eclipse was saving different runs of the tests as different run configurations, and depending on how I ran it (usually using Ctrl+F11), it selected specific tests in the suite, not the whole suite class, and saved those run configurations.
The solution was to delete the new run configurations, and simply right-click the name of the test suite class in the editor, and select Run as -> ScalaTest - Suite. More information
Additionally, you can tweak how Eclipse interprets the run command/shortcut, when you go to Preferences -> Launching:
I have selected Always launch the previously launched application, and now Eclipse isn't trying to dynamically create run configurations anymore. When I switch between the main application or test suits, I have to do it manually using the dropdown near the green Run buton.

C++/CLI, NUnit and Resharper

Say I have an NUnit test project written in C++/CLI, built with the /clr switch. That is, it can reference and use native code, it's not a pure managed assembly.
NUnit can run projects like these, but can this be done from Visual Studio using Resharper? I have R# 5.x, and I can't (can't even see the R# icons by the left edge of the code window to launch the tests). Can the latest version of R# do this?
ReSharper doesn't support C++/CLI, and thus it doesn't show Test icons in the source file. However, it should show tests from output assemblies in Unit Test Explorer (see ReSharper / Windows) and you should be able to right-click project and use Run Tests from context menu.