Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does NUNIT Console work with .NET Core? #487

Closed
maccurt opened this issue Oct 16, 2018 · 17 comments
Closed

Does NUNIT Console work with .NET Core? #487

maccurt opened this issue Oct 16, 2018 · 17 comments
Assignees
Labels

Comments

@maccurt
Copy link

maccurt commented Oct 16, 2018

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.

@maccurt maccurt changed the title Does NUNIT Console work with .NET Core Does NUNIT Console work with .NET Core? Oct 16, 2018
@rprouse
Copy link
Member

rprouse commented Oct 16, 2018

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.

@rprouse rprouse closed this as completed Oct 16, 2018
@rprouse rprouse added this to the Closed Without Action milestone Oct 16, 2018
@rprouse rprouse self-assigned this Oct 16, 2018
@z002Holpp
Copy link

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?

@maccurt
Copy link
Author

maccurt commented Oct 17, 2018

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

@rprouse
Copy link
Member

rprouse commented Oct 21, 2018

@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...

@z002Holpp
Copy link

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.

@elv1s42
Copy link
Contributor

elv1s42 commented Jul 4, 2019

@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?

@rprouse
Copy link
Member

rprouse commented Jul 4, 2019

@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 😉

@elv1s42
Copy link
Contributor

elv1s42 commented Jul 5, 2019

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> SDK 2.1.500 fails to set IsTestProject in net40 projects dotnet/sdk#2690
  3. Microsoft.NET.Test.Sdk package is required too, see Unable to run NUnit unit test. 'Unable to find testhost.dll Please publish your test project and retry.' microsoft/vstest#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.

@rprouse
Copy link
Member

rprouse commented Jul 13, 2019

@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.

@upretyrohan
Copy link

upretyrohan commented Jul 16, 2019

@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 .

@rprouse
Copy link
Member

rprouse commented Jul 22, 2019

@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

@elv1s42
Copy link
Contributor

elv1s42 commented Aug 12, 2019

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:
nunit/nunit3-vs-adapter#222

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

@rprouse
Copy link
Member

rprouse commented Aug 12, 2019

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

@elv1s42
Copy link
Contributor

elv1s42 commented Aug 20, 2019

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).

@ramgkn
Copy link

ramgkn commented Nov 14, 2019

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

@ChrisMaddock
Copy link
Member

@ramgkn Please see #475 for tracking on this.

@ramgkn
Copy link

ramgkn commented Nov 15, 2019

@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??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants