2
votes

I'm new to NUnit and receiving an error when using the nunit3-console.exe to execute my test cases. Below is the command I am using along with the full error.

Command Prompt:

& 'C:\Program Files (x86)\NUnit.org\nunit-console\nunit3-console.exe' C:\Users\sanchez3\Desktop\CICD-Test\cicd-test\NUnitTestProject1\NUnitTestProject1.csproj

The error I am receiving is below.

NUnit Console Runner 3.11.0 (.NET 2.0)
Copyright (c) 2020 Charlie Poole, Rob Prouse
Thursday, February 20, 2020 2:11:26 PM

Runtime Environment
   OS Version: Microsoft Windows NT 6.2.9200.0
   Runtime: .NET Framework CLR v4.0.30319.42000

Test Files
    C:\Users\sanchez3\Desktop\CICD-Test\cicd-test\NUnitTestProject1\NUnitTestProject1.sln


Errors, Failures and Warnings

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

Server stack trace:
   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)
   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)
--
InvalidCastException
Unable to cast transparent proxy to type 'System.Web.UI.ICallbackEventHandler'.
   at NUnit.Framework.Api.FrameworkController.LoadTestsAction..ctor(FrameworkController controller, Object handler)

Test Run Summary
  Overall result: Failed
  Test Count: 0, Passed: 0, Failed: 0, Warnings: 0, Inconclusive: 0, Skipped: 0
  Start time: 2020-02-20 22:11:27Z
    End time: 2020-02-20 22:11:28Z
    Duration: 0.950 seconds

Results (nunit3) saved as TestResult.xml

The project is a new one, with only two basic, NUnit tests. Not sure why I am recieving this error. I've read other threads regarding this, but can't seem to find a solution. Any help is appreciated, thank you!

1
Can you post the code for your NUnit tests? Which NuGet packages do you have installed?Greg Burghardt
StackOverflow says I'm exceeding the maximum amount of characters when I attempt to paste my code. As for the packages, I have NUnit and NUnit3TestAdapter installed. Along with some Selenium packages.Jonathan Sanchez
Post a minimal-reproducible-example. Not entire code. It helps you to determine the root cause.Louis Go
More info may help, but as a shortcut you could tell us what runtime your code is targeting. If it's .NET Core, it's not going to work using NUnit console runner.Charlie
The stack trace does not show anything for your code. It's all framework classes. Did you create that project as an NUnit test project? Which NuGet packages do you have installed?Greg Burghardt

1 Answers

0
votes

Youn should compile your project first and then run your tests like this:

& 'C:\Program Files (x86)\NUnit.org\nunit-console\nunit3-console.exe' 'C:\Compiled solution path\NUnitTestProject1.dll'