SpecFlowOSS / SpecFlow

#1 .NET BDD Framework. SpecFlow automates your testing & works with your existing code. Find Bugs before they happen. Behavior Driven Development helps developers, testers, and business representatives to get a better understanding of their collaboration
https://www.specflow.org/
Other
2.22k stars 752 forks source link

Upgrading xUnit, .NET Test SDK, and SpecFlow.Actions.WindowsAppDriver NuGet packages results in inability to run tests #2691

Open aronweiler opened 1 year ago

aronweiler commented 1 year ago

SpecFlow Version

3.9.74

Which test runner are you using?

xUnit

Test Runner Version Number

SpecFlow.xUnit 3.9.74, xUnit 2.4.2

.NET Implementation

.NET 6.0

Project Format of the SpecFlow project

Sdk-style project format

.feature.cs files are generated using

SpecFlow.Tools.MsBuild.Generation NuGet package

Test Execution Method

Visual Studio Test Explorer

SpecFlow Section in app.config or content of specflow.json

specflow.json:

{
  "$schema": "https://specflow.org/specflow-config.json"
}

specflow.actions.json

{
  "windowsAppDriver": {
    "capabilities": {
      "app": "../../../../WpfExample/bin/Debug/net6.0-windows/WpfExample.exe"
    },
    "WindowsAppDriverPath": "C:\\Program Files (x86)\\Windows Application Driver\\WinAppDriver.exe"
  }
}

Issue Description

After upgrading the NuGet packages on my very simple UI test sample project (see image), I can no longer run UI tests.

specflow sample project references

Running the tests through the Visual Studio (2022) Test Explorer, I receive the following result:

  Message: 
System.AggregateException : One or more errors occurred. (Interface cannot be resolved: SpecFlow.Actions.Configuration.ISpecFlowActionJsonLoader (resolution path: SpecFlow.Actions.WindowsAppDriver.Configuration.WindowsAppDriverConfiguration)) (The following constructor parameters did not have matching fixture data: SpecFlow_Specs_XUnitAssemblyFixture assemblyFixture)
---- BoDi.ObjectContainerException : Interface cannot be resolved: SpecFlow.Actions.Configuration.ISpecFlowActionJsonLoader (resolution path: SpecFlow.Actions.WindowsAppDriver.Configuration.WindowsAppDriverConfiguration)
---- The following constructor parameters did not have matching fixture data: SpecFlow_Specs_XUnitAssemblyFixture assemblyFixture

  Stack Trace: 
----- Inner Stack Trace #1 (BoDi.ObjectContainerException) -----
<>c__DisplayClass3_0.<ResolvePerContext>b__1()
RegistrationWithStrategy.ExecuteWithLock(Object lockObject, Func`1 getter, Func`1 factory, ResolutionList resolutionPath)
TypeRegistration.ResolvePerContext(ObjectContainer container, RegistrationKey keyToResolve, ResolutionList resolutionPath)
RegistrationWithStrategy.Resolve(ObjectContainer container, RegistrationKey keyToResolve, ResolutionList resolutionPath)
ObjectContainer.ResolveObject(RegistrationKey keyToResolve, ResolutionList resolutionPath)
ObjectContainer.Resolve(Type typeToResolve, ResolutionList resolutionPath, String name)
<>c__DisplayClass71_0.<ResolveArguments>b__0(ParameterInfo p)
SelectArrayIterator`2.ToArray()
Enumerable.ToArray[TSource](IEnumerable`1 source)
ObjectContainer.ResolveArguments(IEnumerable`1 parameters, RegistrationKey keyToResolve, ResolutionList resolutionPath)
ObjectContainer.CreateObject(Type type, ResolutionList resolutionPath, RegistrationKey keyToResolve)
<>c__DisplayClass3_0.<ResolvePerContext>b__1()
RegistrationWithStrategy.ExecuteWithLock(Object lockObject, Func`1 getter, Func`1 factory, ResolutionList resolutionPath)
TypeRegistration.ResolvePerContext(ObjectContainer container, RegistrationKey keyToResolve, ResolutionList resolutionPath)
RegistrationWithStrategy.Resolve(ObjectContainer container, RegistrationKey keyToResolve, ResolutionList resolutionPath)
ObjectContainer.ResolveObject(RegistrationKey keyToResolve, ResolutionList resolutionPath)
ObjectContainer.Resolve(Type typeToResolve, ResolutionList resolutionPath, String name)
<>c__DisplayClass71_0.<ResolveArguments>b__0(ParameterInfo p)
SelectArrayIterator`2.ToArray()
Enumerable.ToArray[TSource](IEnumerable`1 source)
ObjectContainer.ResolveArguments(IEnumerable`1 parameters, RegistrationKey keyToResolve, ResolutionList resolutionPath)
ObjectContainer.CreateObject(Type type, ResolutionList resolutionPath, RegistrationKey keyToResolve)
<>c__DisplayClass3_0.<ResolvePerContext>b__1()
RegistrationWithStrategy.ExecuteWithLock(Object lockObject, Func`1 getter, Func`1 factory, ResolutionList resolutionPath)
TypeRegistration.ResolvePerContext(ObjectContainer container, RegistrationKey keyToResolve, ResolutionList resolutionPath)
RegistrationWithStrategy.Resolve(ObjectContainer container, RegistrationKey keyToResolve, ResolutionList resolutionPath)
ObjectContainer.ResolveObject(RegistrationKey keyToResolve, ResolutionList resolutionPath)
ObjectContainer.Resolve(Type typeToResolve, ResolutionList resolutionPath, String name)
ObjectContainer.Resolve(Type typeToResolve, String name)
ObjectContainer.Resolve[T](String name)
ObjectContainer.Resolve[T]()
WindowsAppDriverRuntimePlugin.RuntimePluginTestExecutionLifecycleEventEmitter_BeforeTestRun(Object sender, RuntimePluginBeforeTestRunEventArgs e)
RuntimePluginTestExecutionLifecycleEvents.RaiseBeforeTestRun(IObjectContainer objectContainer)
RuntimePluginTestExecutionLifecycleEventEmitter.RaiseExecutionLifecycleEvent(HookType hookType, IObjectContainer container)
TestExecutionEngine.FireEvents(HookType hookType)
TestExecutionEngine.OnTestRunStart()
TestRunner.OnTestRunStart()
TestRunnerManager.FireTestRunStart()
TestRunnerManager.OnTestRunStart(Assembly testAssembly, IContainerBuilder containerBuilder)
SpecFlow_Specs_XUnitAssemblyFixture.ctor() line 19
RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean wrapExceptions)
----- Inner Stack Trace #2 (Xunit.Sdk.TestClassException) -----

Steps to Reproduce

Clone my repo, build the project, and attempt to run tests via Visual Studio Test Explorer

Link to Repro Project

https://github.com/aronweiler/random/tree/main/SpecFlowExample

aronweiler commented 1 year ago

As a follow-up, I tried reverting the updated NuGet packages one by one, and found that it was the update of the SpecFlow.Actions.WindowsAppDriver that is the culprit.

If I downgrade the SpecFlow.Actions.WindowsAppDriver to v0.1.177, the tests work again.

Going to the SpecFlow.Actions.WindowsAppDriver v0.1.350 causes this issue.

Is there something I am missing in order to get these tests working again?