reqnroll / Reqnroll

Open-source Cucumber-style BDD test automation framework for .NET.
https://reqnroll.net
BSD 3-Clause "New" or "Revised" License
332 stars 37 forks source link

SpecFlow.Actions.* packages are not supported (e.g. error: Interface cannot be resolved: Reqnroll.Actions.Selenium.Configuration.ISeleniumConfiguration) #24

Closed DomZZ closed 6 months ago

DomZZ commented 6 months ago

Reqnroll Version

1.0

Which test runner are you using?

NUnit

Test Runner Version Number

4.0.1

.NET Implementation

.NET 8.0

Test Execution Method

Visual Studio Test Explorer

Content of reqnroll.json configuration file

{ "$schema": "https://schemas.reqnroll.net/reqnroll-config-latest.json", "generator": { "addNonParallelizableMarkerForTags": [ "nonparallelizable" ] }, "runtime": { "missingOrPendingStepsOutcome": "Error" }, "trace": { "traceSuccessfulSteps": true, "traceTimings": false, "minTracedDuration": "0:0:0.0", "stepDefinitionSkeletonStyle": "RegexAttribute" } }

Issue Description

I have converted my Specflow solution to reqnroll, I've followed the migration guide here : https://docs.reqnroll.net/latest/guides/migrating-from-specflow.html#with-namespace-changes

Solution compiles, feature.cs files are generated but when I run a test I have an error with some objects/interfaces that could not be injected in Bodi.ObjectContainerException : ` Message:  BoDi.ObjectContainerException : Interface cannot be resolved: Reqnroll.Actions.Selenium.Configuration.ISeleniumConfiguration (resolution path: ALOP.Hooks) TearDown : BoDi.ObjectContainerException : Interface cannot be resolved: Reqnroll.Actions.Selenium.Configuration.ISeleniumConfiguration (resolution path: ALOP.Hooks)

Stack Trace:  <>cDisplayClass3_0.b1() RegistrationWithStrategy.ExecuteWithLock(Object lockObject, Func1 getter, Func1 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) <>cDisplayClass71_0.b0(ParameterInfo p) SelectArrayIterator2.Fill(ReadOnlySpan1 source, Span1 destination, Func2 func) SelectArrayIterator2.ToArray() ObjectContainer.ResolveArguments(IEnumerable1 parameters, RegistrationKey keyToResolve, ResolutionList resolutionPath)

<57 more frames...> TestExecutionEngine.FireEventsAsync(HookType hookType) TestExecutionEngine.FireScenarioEventsAsync(HookType bindingEvent) TestExecutionEngine.OnScenarioEndAsync() TestRunner.OnScenarioEndAsync() SalariesFeature.TestTearDownAsync() GenericAdapter`1.GetResult() AsyncToSyncAdapter.Await[TResult](Func`1 invoke) AsyncToSyncAdapter.Await(Func`1 invoke) SetUpTearDownItem.RunSetUpOrTearDownMethod(TestExecutionContext context, IMethodInfo method) SetUpTearDownItem.RunTearDown(TestExecutionContext context)` Here is my Hooks constructor : ` public Hooks( IObjectContainer objectContainer, IReqnrollOutputHelper reqnrollOutputHelper, BrowserDriver browserDriver, // Injection doesn't work IBrowserInteractions browserInteractions, // Injection doesn't work ISeleniumConfiguration seleniumConfiguration, // Injection doesn't work ITestThreadExecutionEventPublisher testThreadExecutionEventPublisher) { _objectContainer = objectContainer ?? throw new Exception($"{nameof(objectContainer)} is null"); _reqnrollOutputHelper = reqnrollOutputHelper ?? throw new Exception($"{nameof(reqnrollOutputHelper)} is null"); _browserInteractions = browserInteractions ?? throw new Exception($"{nameof(browserInteractions)} is null"); _browserDriver = browserDriver ?? throw new Exception($"{nameof(browserDriver)} is null"); _seleniumConfiguration = seleniumConfiguration ?? throw new Exception($"{nameof(seleniumConfiguration)} is null"); _testThreadExecutionEventPublisher = testThreadExecutionEventPublisher ?? throw new Exception($"{nameof(testThreadExecutionEventPublisher)} is null"); ` ### Steps to Reproduce Note that I am using Specflow.Actions.Configuration and Specflow.Actions.Selenium. And it fails with : - Specflow.Actions.Selenium.IBrowserInteractions - Specflow.Actions.Selenium.BrowserDriver - Specflow.Actions.Selenium..Configuration.SeleniumConfiguration ### Link to Repro Project _No response_
gasparnagy commented 6 months ago

This is because SpecFlow.Actions are currently not supported. I created a related discussion note here: https://github.com/orgs/reqnroll/discussions/27

I rename this issue for the clarity and close it. We track the porting of SpecFlow.Actions in the discussion topic linked above.

If anyone can help for the porting (mainly to test) please make a note in the discussion topic.

gasparnagy commented 6 months ago

@DomZZ Reqnroll.SpecFlowCompatibility.Actions.* released (v0.1.371) (see https://github.com/orgs/reqnroll/discussions/35).

Could you please try again with Reqnroll.SpecFlowCompatibility.Actions.Selenium?

gasparnagy commented 6 months ago

Closing this now as completed. Please reopen if not working.

konarx commented 6 months ago

@gasparnagy sorry for waking up this issue, but I am facing something very similar. I did the migration steps from SpecFlow as mentioned, I changed nothing to my constructors or bindings and getting this error:

BoDi.ObjectContainerException : Interface cannot be resolved: Microsoft.Playwright.IBrowser (resolution path: MyProject.UITests.Hooks.ScenarioLevelHooks) TearDown : BoDi.ObjectContainerException : Interface cannot be resolved: Microsoft.Playwright.IBrowser (resolution path: MyProject.UITests.Hooks.ScenarioLevelHooks)

gasparnagy commented 6 months ago

@konarx Could you please confirm that you have changed the SpecFlow.Actions.Playwright reference to the Reqnroll.SpecFlowCompatibility.Actions.Playwright package?

konarx commented 6 months ago

@gasparnagy the thing is that I was not using SpecFlow.Actions before the migration. But I gave it a try after you mentioned it and another problem came up. It gave me the error:

Unable to find package Reqnroll.Actions.Configuration. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages, nuget.org

And indeed, in the NuGet repo I can not find the Reqnroll.Actions.Configuration package. A similar NuGet Reqnroll.SpecFlowCompatibility.Actions.Configuration was available, I installed it but still no luck.

gasparnagy commented 6 months ago

@konarx OK, if you haven't used SpecFlow.Actions before then this is a different issue. Undo adding any of the Reqnroll.SpecFlowCompatibility.Actions package for now and please create a new issue where you describe how the Microsoft.Playwright.IBrowser interface was handled in your original SpecFlow solution (as this is not a SpecFlow class there had to be some special code or plugin that handled that.)