Nunit-console: Does NUNIT Console work with .NET Core?

Created on 16 Oct 2018  路  17Comments  路  Source: nunit/nunit-console

https://stackoverflow.com/questions/52835507/does-net-core-work-with-nunit-console-runner

I have a very simple project (.NET CORE 2.1) with one test. I run the console (3.9) and get this error

NUnit.Engine.NUnitEngineException : The NUnit 3 driver encountered an error while executing reflected code.
----> System.InvalidCastException : Unable to cast transparent proxy to type 'System.Web.UI.ICallbackEventHandler'.
--NUnitEngineException
The NUnit 3 driver encountered an error while executing reflected code.

question

Most helpful comment

NUnit Console is compiled using the full .NET Framework and does not currently support .NET Core. To run .NET Core tests from the command line, you need to use dotnet test. For info on how to do this, see https://github.com/nunit/docs/wiki/.NET-Core-and-.NET-Standard

We are looking at creating a .NET Core based console runner, but it is still in the planning stages.

All 17 comments

NUnit Console is compiled using the full .NET Framework and does not currently support .NET Core. To run .NET Core tests from the command line, you need to use dotnet test. For info on how to do this, see https://github.com/nunit/docs/wiki/.NET-Core-and-.NET-Standard

We are looking at creating a .NET Core based console runner, but it is still in the planning stages.

We are also about to migrate our product platform to .Net Core and investigate the necessary actions for our NUnit2-based tests.

A .Net Core based console runner would be highly appreciated.
Any coarse timeline available?

Thank you, I appreciate you getting back to me. I will see if I can get the CLI installed on my Jenkins Virtuals.

@z002Holpp, you don't need to wait for a console runner from us, you can use dotnet test on the command line now with NUnit. A console runner will just add features that are not available currently in the .NET Core test runner. See my link above for more info...

We are looking at creating a .NET Core based console runner, but it is still in the planning stages.

Are there any news regarding a .Net Core based console runner? We are in the phase of migrating some huge NUnit-3 based projects to .Net Core and are waiting urgently for a Core based runner.

@z002Holpp, you don't need to wait for a console runner from us, you can use dotnet test on the command line now with NUnit. A console runner will just add features that are not available currently in the .NET Core test runner. See my link above for more info...

Hi @rprouse !
Does it mean that NUnit Engine extensions like event listeners won't work when using dotnet test command?

@elv1s42 I think event listeners will work with the latest version of the engine, but to be honest, I haven't tested it. If you do, please report back 馃槈

Hi @rprouse,
I've tried to run tests using dotnet test command and faced some issues:

  1. As always I forgot about NUnit Adapter package
  2. The project should be marked as <IsTestProject>true</IsTestProject> https://github.com/dotnet/sdk/issues/2690
  3. Microsoft.NET.Test.Sdk package is required too, see https://github.com/Microsoft/vstest/issues/1870

I have one question regarding the way NUnit Engine discovers the addins. Am I right that it uses this pattern (https://github.com/nunit/nunit-console/blob/master/nuget/engine/nunit.nuget.addins) to locate addins?
Can't find any way to override this file.

@elv1s42 sorry, I've been away and missed your response. The easiest way to add additional addins is to create them as a NuGet package. The engine will look at other installed NuGet packages with the form NUnit.Extension.* and look for addins in the tools directory of the NuGet Package. It's easiest to look at an existing extension.

image

Be aware that extensions for .NET Core are still very new and not well tested, so we'd appreciate feedback. We consider them a work in progress.

@rprouse HI. I have a .netcore nunit test project.I want to implement nunit event listeners in my test project .
Please can you elaborate more on the above screenshot which you have send.

Can you tell me the steps.I have written nunit3 event listener. I want to know how can the nunit3 event listener be found and triggered when i run .netcore test .

@upretyrohan the screenshot is the file layout of another NUnit extension NuGet package. Notice that

  1. The extension DLL is in the tools directory in the NuGet package
  2. There is also an addins file that tells NUnit which DLL to load as the extension
  3. The NuGet package is named nunit.extension.* so that it will be found by the engine.

The addins file only contains one line specifying the DLL to load as the extension,

nunit.v2.driver.dll

Hi @rprouse ,

Thank you for the reply and sorry for late response.
Am I right that the approach you mentioned is related to NUnit Adapter too?
This is the issue I'm talking about:
https://github.com/nunit/nunit3-vs-adapter/issues/222

How will NUnit Test Adapter find the extensions starting from the latest release?

The NUnit Adapter uses the engine, so when it finally supports extensions, they will be found in the same way.

Thank you @rprouse , I'll try the recommended approach for both .NET Framework and .NET Core versions. basically I want to able to install the extension package and start using it without any additional actions (like manual modifications to .addins files).

Team - when can we expect Nunit Console Runner to support DotNet Core.

@ramgkn Please see https://github.com/nunit/nunit-console/issues/475 for tracking on this.

@ChrisMaddock - thank you for sharing the thread related to console runner.

With Vstest or DotNet exe - i am able to execute the test cases; however,

  1. The binding/listener are not considering Specflow hooks/bindings - as our project is on Dotnet Core utilizing Specflow + Nunit.
  2. As Specflow bindings are not getting considered and reports are not getting generated (Extentreports)
  3. What i could see is with Vstest or DotNet, Scenario name from feature file is not getting considered as part of the Method Name; please correct me, if i am wrong, the methods (step definitions) in the assembly files are get executed. If my statement is correct, is it possible to achieve Scenario level execution using Vstest or DotNet exe
  • any interim recommendation that can considered??
Was this page helpful?
0 / 5 - 0 ratings