How to run NUnit tests from inside Visual Studio? - nunit

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!

Related

Visual Studio code run Junit from UI?

I have a maven project (archtype quicksetup).
And I have a testcases annotated with #Test.
Is it possible to run the unit test from the Visual Studio Code UI ?
Microsoft finally released an extension for this exact purpose. However the documentation at this point is definitly lacking. I myself did not get it to work up to this point.
https://blogs.msdn.microsoft.com/visualstudio/2017/12/01/announcing-junit-support-for-visual-studio-code/

Code to generate templates

I just downloaded Visual Studio Code last night. What do I do so that Code will generate, say, a Console Application template?
I've read around the web so far I can't find anything telling me how to create a template.
Q: How do I create and run a new project?
A: VS Code doesn't include a traditional File > New Project dialog or
pre-installed project templates. You'll need to add additional
components and scaffolders depending on your development interests.
With scaffolding tools like Yeoman and the multitude of modules
available through the NPM package manager, you're sure to find
appropriate templates and tools to create your projects.
for details: https://code.visualstudio.com/docs/setup/setup-overview
and a question on SO: Run C# Console Application on Visual Studio Code Editor on Windows

Can Powershell Tools for Visual Studio 2015 projects make Project References

I have a Powershell Tools for Visual Studio 2015 project that is a script module. I would like to add a project reference to a .NET 4.5 class library that is also a project in the same solution. From a visual perspective the dependency is listed under the references tree in the powershell project but it has the warning overlay icon on it. When running the pester tests they error out with a type resolution error (Cannot find type [IHE.Cda.TrifoliaParser]: verify that the assembly containing this type is loaded). I cannot find any documentation which indicates whether what I am attempting is even possible. Thus my question is whether it is possible or if the references list is just a artifact of being in visual studio.
Solution Explorer View
The References are an artifact of VisualStudio. It would be possible to generate an Import-Module <PathToThe>.dll line on top of every script in your project, but that's very obtrusive, and not every script will need all the dependencies.

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.

GWT Post build command in Eclipse

I am starting getting used to Eclipse, but I have much more experience with Visual Studio. In Visual Studio it is possible to run auto commands after the build has finished.
Now I am creating a GWT project and several other projects at once in one solution (or workspace) in Eclipse. Some files which are compiled with the GWT project needs to be copied to another location when they have been compiled. I am currently doing this manually and would like to do it automatically. I am not doing it often, since the project works fine in debug mode (...?gwt.codesvr=localhost:9997).
But where is the location for executing a post build command for a GWT project in eclipse? Is it possible?
Just open project properties, choose 'Builders' item and click on 'New...' button.
Good question! I'm using Eclipse since about 2003, and I remember that I also wanted a functionality like that back then. However, I got so used to using ant for any serious build, that I completely forgot about it.
There is some useful ant integration in Eclipse (e.g. the ant view), and if you create your GWT project with webAppCreator you already get a few good ant targets you can build upon.
It would still be nice sometimes to have something more GUI-like to do simple multi-step builds with Eclipse. I haven't found anything like that yet, but it's absolutely possible that it exists, especially as a plugin.