question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to run .NetCore 2.0 tests from command line using Nunit3-console.exe

See original GitHub issue

I have a simple .Net Core 2.0 project containing only the following tests:

`using NUnit.Framework;

namespace TestStuffCore { [TestFixture] public class Class1 {

    [Test]
    public void TestStuff1()
    {
        Assert.AreEqual(1 + 1, 2, "Equal");
    }

    [Test]
    public void TestStuff2()
    {
        Assert.AreEqual(1 + 1, 3, "Not equal");
    }
}

} `

Nuget packages installed: Microsoft.NET.Test.Sdk v15.5.0 Microsoft.NETCore.App v2.0.0 NUnit v3.9.0 NUnit.Console v3.8.0 NUnit3TestAdapter v3.9.0

Running them from Visual Studio Test Explorer, everything works fine.

Running them from console line fails with the following error:

..nuget\packages\nunit.consolerunner\3.8.0\tools\nunit3-console.exe “C:\Users\Cosmin Gramada\source\repos\TestStuff\TestStuffCore\bin\Debug\netcoreapp2.0\TestStuffCore.dll” NUnit Console Runner 3.8.0 Copyright © 2018 Charlie Poole, Rob Prouse

Runtime Environment OS Version: Microsoft Windows NT 10.0.16299.0 CLR Version: 4.0.30319.42000

Test Files C:\Users\Cosmin Gramada\source\repos\TestStuff\TestStuffCore\bin\Debug\netcoreapp2.0\TestStuffCore.dll

Errors, Failures and Warnings

  1. Error : NUnit.Engine.NUnitEngineException : An exception occurred in the driver while loading tests. ----> System.IO.FileNotFoundException : Could not load file or assembly ‘nunit.framework’ or one of its dependencies. The system cannot find the file specified. –NUnitEngineException

Server stack trace: at NUnit.Engine.Runners.DirectTestRunner.LoadDriver(IFrameworkDriver driver, String testFile, TestPackage subPackage) at NUnit.Engine.Runners.DirectTestRunner.LoadPackage() at NUnit.Engine.Runners.DirectTestRunner.EnsurePackageIsLoaded() at NUnit.Engine.Runners.DirectTestRunner.RunTests(ITestEventListener listener, TestFilter filter) at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs) at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg)

Exception rethrown at [0]: at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) at NUnit.Engine.ITestEngineRunner.Run(ITestEventListener listener, TestFilter filter) at NUnit.Engine.Runners.ProcessRunner.RunTests(ITestEventListener listener, TestFilter filter) –FileNotFoundException at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) at System.Activator.CreateInstance(String assemblyString, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityInfo, StackCrawlMark& stackMark) at System.Activator.CreateInstance(String assemblyName, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityInfo) at System.AppDomain.CreateInstance(String assemblyName, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityAttributes) at System.AppDomain.CreateInstanceAndUnwrap(String assemblyName, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityAttributes) at System.AppDomain.CreateInstanceAndUnwrap(String assemblyName, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityAttributes) at NUnit.Engine.Drivers.NUnit3FrameworkDriver.CreateObject(String typeName, Object[] args) at NUnit.Engine.Drivers.NUnit3FrameworkDriver.Load(String testAssemblyPath, IDictionary`2 settings) at NUnit.Engine.Runners.DirectTestRunner.LoadDriver(IFrameworkDriver driver, String testFile, TestPackage subPackage)

Test Run Summary Overall result: Failed Test Count: 0, Passed: 0, Failed: 0, Warnings: 0, Inconclusive: 0, Skipped: 0 Start time: 2018-01-30 15:54:59Z End time: 2018-01-30 15:54:59Z Duration: 0.547 seconds

Results (nunit3) saved as TestResult.xml

Further investigations: 1.) Running the exact same test code from a project targeting .Net Framework works as expected. 2.) Running the exact same test code from a project targeting .Net Core, but using NUnit.Console v3.7.0 results into the following error:

..nuget\packages\nunit.consolerunner\3.7.0\tools\nunit3-console.exe “C:\Users\Cosmin Gramada\source\repos\TestStuff\TestStuffCore\bin\Debug\netcoreapp2.0\TestStuffCore.dll” NUnit Console Runner 3.7.0 Copyright © 2017 Charlie Poole, Rob Prouse

Runtime Environment OS Version: Microsoft Windows NT 10.0.16299.0 CLR Version: 4.0.30319.42000

Test Files C:\Users\Cosmin Gramada\source\repos\TestStuff\TestStuffCore\bin\Debug\netcoreapp2.0\TestStuffCore.dll

Errors, Failures and Warnings

  1. Error : An exception occurred in the driver while loading tests.

Server stack trace: at NUnit.Engine.Runners.DirectTestRunner.LoadDriver(IFrameworkDriver driver, String testFile, TestPackage subPackage) at NUnit.Engine.Runners.DirectTestRunner.LoadPackage() at NUnit.Engine.Runners.DirectTestRunner.EnsurePackageIsLoaded() at NUnit.Engine.Runners.DirectTestRunner.RunTests(ITestEventListener listener, TestFilter filter) at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs) at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg)

Exception rethrown at [0]: at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) at NUnit.Engine.ITestEngineRunner.Run(ITestEventListener listener, TestFilter filter) at NUnit.Engine.Runners.ProcessRunner.RunTests(ITestEventListener listener, TestFilter filter)

Test Run Summary Overall result: Failed Test Count: 0, Passed: 0, Failed: 0, Warnings: 0, Inconclusive: 0, Skipped: 0 Start time: 2018-01-30 15:55:16Z End time: 2018-01-30 15:55:16Z Duration: 0.549 seconds

Results (nunit3) saved as TestResult.xml

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:12 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
ChrisMaddockcommented, Feb 15, 2018

@spokcarls dotnet test is the way to go at the moment. As Rob says in https://github.com/nunit/nunit-console/issues/364#issuecomment-361706848 - we’re hoping to support .NET Core in the full engine/console at some point - as ever, that’s based on willing contributors!

1reaction
CharliePoolecommented, Jan 30, 2018

We should definitely give more information from the runner itself.

See the wiki here: https://github.com/nunit/docs/wiki/.NET-Core-and-.NET-Standard

Read more comments on GitHub >

github_iconTop Results From Across the Web

Does .NET Core work with the NUnit console runner?
NET Core. To run .NET Core tests from the command line, you need to use dotnet test . For information on how to...
Read more >
Testing .NET Core using NUnit 3 - Alteridem
The test runner that ships with NUnit 3, nunit3-console.exe is a .NET 2.0 application that cannot run NUnit tests that reference the portable ......
Read more >
Console Command Line
If the NUnit V2 framework driver is installed, test assemblies may be run based on any version of the NUnit framework beginning with...
Read more >
NUnit Support in TeamCity
Use the NUnit console with TeamCity Add-in for NUnit. Import XML test results via the XML Test Report plugin. Use the command-line NUnit...
Read more >
Unable to run my specFlow code through Console
I am unable to run SpecFlow through console file. My NUnit Versions: C:\Users\.nuget\packages\nunit.consolerunner\3.11.1\tools>nunit3-console.exe ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found