Unable to run .NetCore 2.0 tests from command line using Nunit3-console.exe
See original GitHub issueI 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
- 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
- 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:
- Created 6 years ago
- Comments:12 (8 by maintainers)
@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!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