Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The step bindings from external assembly are not found #1315

Closed
godrose opened this issue Oct 30, 2018 · 20 comments

Comments

@godrose
Copy link

@godrose godrose commented Oct 30, 2018

SpecFlow Version:

  • 3.0

Used Test Runner

  • Xunit

Version number: 3.0.132-beta

Visual Studio Version

  • VS 2017

Are the latest Visual Studio updates installed?

  • Yes

.NET Framework:

  • .NET Core 2.1

Test Execution Method:

  • Visual Studio Test Explorer

<SpecFlow> Section in app.config

{
"bindingCulture": {
"language": "en-us"
},
"language": {
"feature": "en-us"
},

"plugins": [],
"stepAssemblies": [
{
"assembly": "SpecflowNetCoreTest.Steps.Adapters"
}
]
}

Repro Project

None

Issue Description

Bindings from external assembly don't work.

Steps to Reproduce

  1. Create a new .NETCore xUnit Test Project
  2. Download the SpecFlow SpecFlow.XUnit SpecFlow.MSBuild packages
  3. Add a .feature file via 'Add new Item' dialog
  4. Create a new .NETStandard Project
  5. Add a step definition via 'Add new item' dialog in this project
  6. Add a reference to this project to the test project
  7. Add s configuration file via 'Add new item' dialog - see the example above
  8. Run the test

Expected: The test is green
Actual: The test is red with 'Unable to find step mapping' error message.

@godrose

This comment has been minimized.

Copy link
Author

@godrose godrose commented Oct 30, 2018

It appears the workaround is very simple.
Please add this to the 'SpecFlow configuration' template -> 'Copy to output directory - Always'

@SabotageAndi

This comment has been minimized.

Copy link
Collaborator

@SabotageAndi SabotageAndi commented Oct 30, 2018

Ah, we don't set 'Copy to output directory' for the specflow.json.
We should fix this => so I reopen it that we don't forget it.

@Regenhardt

This comment has been minimized.

Copy link
Contributor

@Regenhardt Regenhardt commented Feb 5, 2019

Do we have to implement an IWizard for the template? Couldn't find another way to set that attribute.

@SabotageAndi

This comment has been minimized.

Copy link
Collaborator

@SabotageAndi SabotageAndi commented Feb 5, 2019

This has to be fixed in the NuGet packages.

Putting this into a SpecFlow.targets file and adding it to the NuGet package should work.

<PropertyGroup>
    <BuildDependsOn>
      CopySpecFlowJsonToOutput;
      $(BuildDependsOn)
    </BuildDependsOn>
    <CleanDependsOn>
      $(CleanDependsOn)
    </CleanDependsOn>
    <RebuildDependsOn>
      CopySpecFlowJsonToOutput;
      $(RebuildDependsOn)
    </RebuildDependsOn>
  </PropertyGroup>

  <Target Name="CopySpecFlowJsonToOutput" >

    <ItemGroup>
      <None Condition="'%(None.Filename)' == 'specflow.json'" >
        <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
        <Visible>true</Visible>
      </None>
    </ItemGroup>

  </Target>
@Regenhardt

This comment has been minimized.

Copy link
Contributor

@Regenhardt Regenhardt commented Feb 9, 2019

This packaging stuff is complicated. Do I make that file a solution item in .Build solution folder? How do I tell nuget to use it as targets? Will it just do it becuase it's .targets?
Sorry I'm really lost. MSDN isn't really helpful, unless I build a completely new project.

@SabotageAndi

This comment has been minimized.

Copy link
Collaborator

@SabotageAndi SabotageAndi commented Feb 11, 2019

Yeah, manual nuget package creation is complex.
You have to add the file into https://github.com/techtalk/SpecFlow/tree/master/TechTalk.SpecFlow/build (new folder needed) and add <file src="build\**\*" target="build" /> into the https://github.com/techtalk/SpecFlow/blob/master/TechTalk.SpecFlow/SpecFlow.nuspec like https://github.com/techtalk/SpecFlow/blob/master/Plugins/TechTalk.SpecFlow.xUnit.Generator.SpecFlowPlugin/SpecFlow.xUnit.nuspec#L24

When you compile the solution, the packages are put into the GeneratedNuGetPackages in the repository root folder. You can use the https://github.com/NuGetPackageExplorer/NuGetPackageExplorer to check if the file is really in the generated package.

@Regenhardt

This comment has been minimized.

Copy link
Contributor

@Regenhardt Regenhardt commented Mar 26, 2019

I'm not sure whether it's my nuget package explorer or the target stuff I don't understand well enough, but one of those things lets me not do this properly. sorry about that.
I can push my current setup later, maybe there's an obvious error I don't see.

lavjamanxd pushed a commit to lavjamanxd/allure-csharp that referenced this issue May 15, 2019
Specflow changes
- App.config does not define a plugins now, instead it discovers it by
 finding assemblies in a form of *.SpecFlowPlugin.dll
- Also unit test providers are deprecated it uses dedicated nuget packages
for it.
- Also some interface changes

Important:
Don't forget to set App.config -> copy always
And this line should be included in the App.config
 <stepAssembly assembly="Allure.SpecFlowPlugin" />
(related ticket: techtalk/SpecFlow#1315)
@kooolandy

This comment has been minimized.

Copy link

@kooolandy kooolandy commented Jun 10, 2019

Not sure if I read the OP properly but I have reference bindings from external assemblies using .NET Core 2.1. where the specflow.json contains the following:
{ "stepAssemblies": [ { "assembly": "<YourSeleniumBindings>" } ] }

The assembly would be included in the project with "Copy Local" set to "Yes"
PS Not using appsettings.config any more

@Simmo7

This comment has been minimized.

Copy link

@Simmo7 Simmo7 commented Jul 25, 2019

I've converted my stepAssemblies from App.config into specflow.json and changed Copy Local to Copy Always but the bindings are still not being found, any tip for anything else I can try? I've only just updated from 2.4 to 3.

@SabotageAndi

This comment has been minimized.

Copy link
Collaborator

@SabotageAndi SabotageAndi commented Jul 25, 2019

@Simmo7 at runtime or from the VS Extension?

@Simmo7

This comment has been minimized.

Copy link

@Simmo7 Simmo7 commented Jul 25, 2019

In VS from the Extension. The bindings just remain purple.

@SabotageAndi

This comment has been minimized.

Copy link
Collaborator

@SabotageAndi SabotageAndi commented Jul 25, 2019

@Simmo7 Ok, that's an issue since years. The VS Extension has problems with external assemblies. Sadly it is nothing that is easily fixable.

@Simmo7

This comment has been minimized.

Copy link

@Simmo7 Simmo7 commented Jul 25, 2019

I've never had a problem with these previously in Specflow 2.4, I added the project the bindings are in to stepAssemblies in App.config file as normal and add the project as a reference to the one I'm using them in. Never had a problem until updating to 3.0 where I've attempted the same thing but with the specflow.json file, but they aren't being found.

@SabotageAndi

This comment has been minimized.

Copy link
Collaborator

@SabotageAndi SabotageAndi commented Jul 25, 2019

You have the latest VS Extension installed?

@Simmo7

This comment has been minimized.

Copy link

@Simmo7 Simmo7 commented Jul 25, 2019

Yeah that's what I'm trying to do, update to 3.0.225.

@SabotageAndi

This comment has been minimized.

Copy link
Collaborator

@SabotageAndi SabotageAndi commented Jul 25, 2019

The VS Extension is not the NuGet packages.

image

Your version should be 2019.0.31.31805

@Simmo7

This comment has been minimized.

Copy link

@Simmo7 Simmo7 commented Jul 25, 2019

Sorry, yes I have this set to update automatically and that is the version I have.

@brindly

This comment has been minimized.

Copy link

@brindly brindly commented Aug 2, 2019

I am facing a similar issue, I am able to run the test but the steps are still in purple color in the feature file and couldn't navigate to the steps by pressing F12 or by selecting 'Go To Definition'

@jollygardener

This comment has been minimized.

Copy link

@jollygardener jollygardener commented Sep 6, 2019

I have extension version 2019.0.36.11860 and also have this problem

@lock

This comment has been minimized.

Copy link

@lock lock bot commented Oct 23, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Oct 23, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
7 participants
You can’t perform that action at this time.