How to debug test from test explorer window in visual studio with Nunit runner - nunit

How can I debug my nunit test listed in test explorer in visual studio.I have added nunit adapter and tests are listed in explorer,but if I start debugging fixture from explorer it runs using Vstest.execution engine,is it possible to make explorer use nunit runner?though Vstest.execution engine recognises nunit i want tio run using Nunit runner

When VsTest runs NUnit tests, it is using the NUnit adapter that you have installed, which calls the NUnit execution engine.
Is there something particular that is not working for you in running tests this way that you need some help with?

Related

Is there an extension for running `mstest` tests in Visual Studio Code

I created a new .NET Core 2.1 solution to learn some new tools. In this solution I have two C# projects: a class library and mstest. I want to run the tests in my mstest project in Visual Studio Code. However, I do not see a way to do this.
I looked through the Visual Studio Code extensions, however, I didn't see an extension that targets mstest projects. Am I missing something?
If you are running .NET Core it looks like you can run unit tests by just typing dotnet tests. There is more documentation MS Docs .NET Unit Testing. But if you wanted to run MS Tests you don't need Visual Studio to do so it comes with its own console, or CLI. Its documented here and more about the command line tool here

XUnit tests running fast in VS2017 but very slowly on VSTS build agent

I've recently migrated ~2000 pure unit tests from MSTest to XUnit. The tests are contained in approximately 10 tests projects and are configured to run in parallel by test collection and assembly. I've installed the visual studio test runner nuget package and when running locally in Visual Studio 2017 the tests take ~25s to complete. However, the tests take ~30 minutes (!) when they are run on a VSTS build agent. I've tried tuning all the various flags in xunit to try and speed up the tests on the build agent but the best runtime I've managed to achieve is ~20 minutes. Has anyone else experienced such a massive discrepancy between xunit test runtimes?
I managed to resolve the issue by updating the xunit nuget packages to the latest BETA version (v2.3.0-beta3-build3705) which has reduced the unit test runtime on the agent to a reasonable 60s.

Update Nunit Console Runner to version 3 on Sharpdevelop

I am having several problems running tests with new functionalities of Nunit Framework version 3.5
On SharpDevelop 5, I checked the version of Nunit Console installed on SharpDevelop 5 (SharpDevelop\5.1\bin\Tools\NUnit) and it is old (2.6.3.0). I think that by performing the upgrade to Nunit Console Version 3 I will not have any more problems.
Looking on Nuget I found NUnit Console Runner Version 3, but it is not being installed on SharpDevelop 5.
So, how can I upgrade the Nunit Console Runner?
This was interesting - I learned something.
SharpDevelop comes with an nunit-console.exe 2.6.3 file which is not the same as our (nunit's) nunit-console.exe 2.6.3. All the other nunit assemblies appear to be the distributed NUnit binaries but this one is where they have added some new options and made some fixes. Consequently, I don't believe you can just drop in any release of NUnit you like and have it work.
In any case, even without the special executable build, you could not just drop in nunit3-console and the associated NUnit 3 assemblies. NUnit 3 is actually an entirely new program. It works differently from earlier releases internally and has a different set of options on the command-line.
Consequently, you are forced to stick with NUnit 2.6.x so long as you want to use the SharpDevelop runner. I'll look into possibly helping them with an upgrade (probably a new NUnit3 tool) if they are interested.

CI Build Error with Visual Studio Test step after .Net 4.6 upgrade - Executor process exited; There was no endpoint listening at net.pipe

I just upgraded all of the projects in my solution to point to .Net 4.6 (There is a web app, some class libraries, a database project, etc.). I have a CI build set up in Visual Studio Team Services (using the new build system, not XAML) which was building successfully prior to the upgrade. This build definition runs Debug, Staging, and Production builds and the build definition is comprised of two steps:
Visual Studio Build
Visual Studio Test
Prior to this framework upgrade, everything was building fine. I upgraded and built everything locally and it all worked great too. I could run the tests and got green across the board. Now, when I checked my code in it kicked off the CI build, and I got the following error/s on the "Visual Studio Test" step (taken from the logs):
2015-09-18T19:08:02.1212067Z Microsoft (R) Test Execution Command Line Tool Version 14.0.23107.0
2015-09-18T19:08:02.1489666Z Copyright (c) Microsoft Corporation. All rights reserved.
2015-09-18T19:08:02.8906952Z Starting test execution, please wait...
2015-09-18T19:08:03.3713251Z Warning: Using Isolation mode to run tests as required by effective Platform:X86 and .Net Framework:Framework35 settings for test run. Use the /inIsolation parameter to suppress this warning.
2015-09-18T19:08:07.4457804Z ##[error]Error: Executor process exited.
2015-09-18T19:08:07.4457804Z ##[error]
2015-09-18T19:08:07.4557251Z ##[error]Error: There was no endpoint listening at net.pipe:[...redacted...] that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.
2015-09-18T19:08:07.4557251Z ##[error]
2015-09-18T19:08:07.7730938Z ##[error]VSTest Test Run failed with exit code: 1
2015-09-18T19:08:07.8043435Z ##[warning]No results found to publish.
The Visual Studio Build passes for all three configurations, and the Test step only fails for Debug because it cannot find any tests for the other two configurations. Additionally, my builds are running off of an Azure VM that I stood up to act as a build server, and when I run the CI build using the Hosted build controller the Test step passes, because it cannot find any tests to execute, but the warning about using 'Isolation mode to run tests...' is still printed out in the log.
Is this a known issue? Has anyone else encountered this after a 4.6 upgrade or in another context in VSTS?
Edit: the .Net Framework 4.6 SDK and targeting pack/s ARE installed on the build machine:
The first warning suggests that the tests are running on .NET 3.5:Warning: ... effective Platform:X86 and .Net Framework:Framework35 ...
So I explicitly set the vstest.console framework version to 4.5. (At this time 4.6 is not an available option). That resolved these symptoms for me.
To do so edit the Visual Studio Test build step. On the Build tab of the step settings, expand the Advanced section, and set Other console options to /Framework:Framework45.
I found a workaround for the time being that works for now. I modified the settings for the Visual Studio Test build step as follows:
On the Build tab of the step settings, expand the "Advanced" section, and change the VSTest version to "Visual Studio 2013".
That's all it took for me. I tried this because my build was working when I switched to the Hosted build controller, and this was one of the differences between the two in the logs. This is the only thing that I changed, and it worked. I have no idea WHY the Visual Studio 2015 VSTest version doesn't work, but will look into it more and add to this if I find anything...
I experienced this error (specifically the VSTest exit code) after upgrading a test project to 4.6.1. The issue was that the packages.config didn't update the test framework runner pacakge correctly leaving it at .Net 3.5. Updating the target framework resolved the problem.
After installing .Net Framework 3.5 feature everything was OK! See "cottsay" comment at https://github.com/Microsoft/vsts-tasks/issues/572

How to test MS Fakes when NUNIT is installed?

I installed TestDriven.NET to test some older NUNIT tests. Now I need to test some MS Fakes based tests. However, the only options I have is to run and debug tests are TestDriven.NET.
I'm using VS.NET 2013.
How do I re-enable MS Fakes test runner?