Skip to main content

Unable to run my specFlow code through Console

Comments

14 comments

  • Jordan Western

    Hi Kiran,

    here you can see the required files for SpecFlow and NUnit integration.

    SpecFlow.NUnit is required to generate the correct code behind file for the execution engine to understand the tests properly.

    please can you add the required packages and let me know how you get on.

    P.S. if you have queries please add them to the general discussions section of the site, otherwise they may not be picked up in the same time frame because they may be missed. Better still, submit a support ticket :)

    0
  • Kiran Kumar

    Jordan Western Thanks for your quick reply. Going forward, I will post my questions in General Discussions section. 

    I have already installed the required plugins.

    Here's the list:

    Microsoft.NET.Test.Sdk - 16.11.0
    NUnit - 3.13.1
    NUnit.Console - 3.11.1
    NUnit.ConsoleRunner - 3.11.1
    NUnit3TestAdapter - 4.0.0
    SpecFlow - 3.9.22
    SpecFlow.NUnit - 3.9.22
    SpecFlow.Plus.LivingDocPlugin - 3.9.57
    SpecRun.Runner - 3.9.7

    Still facing an issue. 

    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.

    0
  • Jordan Western

    Kiran Kumar,

    You have a reference to SpecRun.Runner - 3.9.7 which is conflicting, this is my first observation.

    Do your tests execute from inside of Visual Studio? And are the code behind files using NUnit references? My concern is that they are being generated for the SpecFlow + Runner and not NUnit, but i can be sure because I can't see your project :)

    Can you please send me the command you are using to execute the tests from the command line?

    I will try and replicate it.

    0
  • Kiran Kumar

    Command: C:\Users\.nuget\packages\nunit.consolerunner\3.11.1\tools>nunit3-console.exe D:\automation\bin\Debug\netcoreapp3.1\automation.dll

    0
  • Jordan Western

    Hi Kiran Kumar,

    Did you acknowledge my other suggestions? :)

    Do these execute from the IDE?

    Please check which implementation the code behind files are using. If you want to use NUnit you only need the SpecFlow.NUnit package.

    0
  • Kiran Kumar

    Jordan Western I have tried in all possible ways. My issue is not resolved yet. 

    I am trying to run my test case for specific category, can you please help on this.

    C:\Users\\.nuget\packages\nunit.consolerunner\3.11.1\tools>nunit3-console.exe "D:\Automation\bin\Debug\netcoreapp3.1\la-automation.dll" --where "cat=KK"
    NUnit Console Runner 3.11.1 (.NET 2.0)
    Copyright (c) 2020 Charlie Poole, Rob Prouse
    Sunday, April 3, 2022 9:25:35 PM

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

    Test Files
        D:\Automation\bin\Debug\netcoreapp3.1\la-automation.dll

    Test Filters
        Where: cat=KK


    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: 2022-04-03 15:55:36Z
        End time: 2022-04-03 15:55:38Z
        Duration: 1.650 seconds

    Results (nunit3) saved as TestResult.xml

    0
  • Kiran Kumar

    When I run using vstest.console.exe, test case got executed successfully, but throwing a different error:

    How to resolve this error?

    C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\CommonExtensions\Microsoft\TestWindow>vstest.console.exe "D:\Automation\bin\Debug\netcoreapp3.1\automation.dll" /TestCaseFilter:"TestCategory=KK"
    Microsoft (R) Test Execution Command Line Tool Version 16.11.0
    Copyright (c) Microsoft Corporation.  All rights reserved.

    Starting test execution, please wait...
    A total of 1 test files matched the specified pattern.
    NUnit Adapter 4.0.0.0: Test execution started
    Running selected tests in D:\Automation\bin\Debug\netcoreapp3.1\automation.dll
       NUnit3TestExecutor discovered 1 of 1 NUnit test cases using Current Discovery mode, Non-Explicit run
    LA Path:---C:\Program Files (x86)\Len\Aena.exe
    Maximized the window
    Given Aena is installed for Navigation
    Desktop Session is not null
    -> done: NavigationSteps.GivenAeenaIsInstalledForNavigation() (3.0s)
    When Open Aena for Navigation
    Verified App Title
    -> done: NavigationSteps.WhenOpenAenaForNavigation() (3.2s)
    Then User can see Home on left navigation bar
    Home Button Status:---True
    Verified Home Navigation
    -> done: NavigationSteps.ThenUserCanSeeHomeOnLeftNavigationBar() (0.5s)
    Closed the window

      Passed A239_TestStep01_VerifyNavigationBar [15 s]
    NUnit Adapter 4.0.0.0: Test execution complete
    An exception occurred while invoking executor 'executor://specrun/executorV3.9.7': Exception has been thrown by the target of an invocation.
    Stack trace:
       at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean wrapExceptions, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& hasNoDefaultCtor)
       at System.RuntimeType.CreateInstanceDefaultCtorSlow(Boolean publicOnly, Boolean wrapExceptions, Boolean fillCache)
       at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, Boolean wrapExceptions)
       at System.Activator.CreateInstance(Type type, Boolean nonPublic, Boolean wrapExceptions)
       at System.Activator.CreateInstance(Type type)
       at Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.TestPluginManager.CreateTestExtension[T](Type extensionType)
       at Microsoft.VisualStudio.TestPlatform.Common.ExtensionFramework.Utilities.LazyExtension`2.get_Value()
       at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Execution.BaseRunTests.RunTestInternalWithExecutors(IEnumerable`1 executorUriExtensionMap, Int64 totalTests)

    Inner exception: Could not load file or assembly 'TechTalk.SpecRun.Common, Version=3.9.0.0, Culture=neutral, PublicKeyToken=d0fc5cc18b3b389b'. The system cannot find the file specified.

    Stack trace:
       at TechTalk.SpecRun.Framework.CurrentExecutionModelSettings.GetCurrent()
       at TechTalk.SpecRun.Framework.SubfolderAssemblyResolver.Enable()
       at TechTalk.SpecRun.VisualStudio.TestAdapter.SpecRunTestExecutor..ctor()


    Test Run Failed.
    Total tests: 1
         Passed: 1
     Total time: 27.1633 Seconds

    C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\CommonExtensions\Microsoft\TestWindow>

    Configuration:

    NUnit - 3.13.1

    NUnit.Console - 3.11.1

    NUNit.ConsoleRunner - 3.11.1

    NUnit3TestAdapter - 4.0.0

    SpecFlow - 3.9.40

    SpecFlow.Actions.WindowsAppDriver - 0.1.177

    SpecFlow.NUnit - 3.9.40

     

    Tagging - kishan.patel Vidhya Venugan Jordan Western - Can you please help on this? 

    Thank you

     

    0
  • Andreas Willich

    Because of the error message "An exception occurred while invoking executor 'executor://specrun/executorV3.9.7': Exception has been thrown by the target of an invocation.", I think you still have files from the SpecFlow+ Runner in your output directory. 

    Clean them and try again.

    0
  • Kiran Kumar

    Hi Andreas Willich you want me to un-install the plugin?

    0
  • Andreas Willich

    If you want to use NUnit, yes, remove this NuGet package (that is the correct term here)

    0
  • Kiran Kumar

    Andreas Willich I have uninstalled SpecRun.Runner and ran through command line, it is still throwing an error. . Please check the details below

    C:\Users\.nuget\packages\nunit.consolerunner\3.11.1\tools>nunit3-console.exe "D:\Automation\bin\Debug\netcoreapp3.1\automation.dll" --where "Cat=KK"
    NUnit Console Runner 3.11.1 (.NET 2.0)
    Copyright (c) 2020 Charlie Poole, Rob Prouse
    Monday, April 4, 2022 9:43:26 PM

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

    Test Files
        D:\Automation\bin\Debug\netcoreapp3.1\automation.dll

    Test Filters
        Where: Cat=KK


    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: 2022-04-04 16:13:26Z
        End time: 2022-04-04 16:13:28Z
        Duration: 1.560 seconds

    Results (nunit3) saved as TestResult.xml

    0
  • Kiran Kumar

    And also I have tried using VS Console, the is throwing a different error:

    C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\CommonExtensions\Microsoft\TestWindow>vstest.console.exe "D:\Automation\bin\Debug\netcoreapp3.1\automation.dll" /TestCaseFilter:"TestCategory=KK"

      Failed LA2_VerifyNavigationBar [8 s]
      Error Message:
       System.NullReferenceException : Object reference not set to an instance of an object.
    TearDown : System.NullReferenceException : Object reference not set to an instance of an object.
      Stack Trace:
         at automation.Settings.Base.AenaApp() in D:\automation\Settings\Base.cs:line 49
       at automation.Hooks.HooksSetup.BeforeScenarioStart(ScenarioContext sc) in D:\automation\Hooks\HooksSetup.cs:line 91
       at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.FireEvents(HookType hookType)
       at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.FireScenarioEvents(HookType bindingEvent)
       at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.OnScenarioStart()
       at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.OnAfterLastStep()
       at TechTalk.SpecFlow.TestRunner.CollectScenarioErrors()
       at automation.Features.LA2_Navigation_TestsFeature.ScenarioCleanup()
       at automation.Features.LA2_Navigation_TestsFeature.LA2_VerifyNavigationBar() in D:\automation\Features\Navigation.feature:line 15
    --TearDown
       at automation.Hooks.HooksSetup.AfterScenario() in D:\automation\Hooks\HooksSetup.cs:line 161
       at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.FireEvents(HookType hookType)
       at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.FireScenarioEvents(HookType bindingEvent)
       at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.OnScenarioEnd()
       at TechTalk.SpecFlow.TestRunner.OnScenarioEnd()
       at automation.Features.LA2_VerifyNavigationBar_TestsFeature.TestTearDown()
      Standard Output Messages:
     LA Path:---C:\Program Files (x86)\Len\Aena.exe
     Failed to locate opened application window with appId: C:\Program Files (x86)\Len\Arena.exe, and processId: 19060

    0
  • Kiran Kumar

    Andreas Willich Do you have 5min time.. Shall we connect quickly and resolve the issue . 

     

    0
  • Andreas Willich

    Sorry, but we don't do 1:1 support. 

    About your errors:

    The last post is an exception in your code.

    > at legion_arena_automation.Settings.Base.AenaApp() in D:\automation\Settings\Base.cs:line 49

    There is the NullRefException happening. 

    The post before that is an NUnit error with no SpecFlow code executed. And I never saw this error before. Something is very strange with your NUnit setup.

    0

Please sign in to leave a comment.

Powered by Zendesk