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

Fix multiple plugin load #1126

Merged
merged 6 commits into from
Apr 25, 2018
Merged

Fix multiple plugin load #1126

merged 6 commits into from
Apr 25, 2018

Conversation

vitezp
Copy link
Contributor

@vitezp vitezp commented Apr 23, 2018

According to #888 there were multiple users having the same problem.
Problem was that plugins are once loaded from app.config and then it loads configuration through method LoadConfiguration which calls the same loading method. This results in the same plugin being in the collection twice. Some Equals method together with distinct should resolve the issue but this is IMO more elegant way.
This simple one-liner should resolve the issue as it does in my simulated environment.

Types of changes

  • Bug fix (non-breaking change which fixes an issue).
  • New feature (non-breaking change which adds functionality).
  • Breaking change (fix or feature that would cause existing functionality to not work as expected).

Checklist:

  • I've added tests for my code.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added an entry to the changelog

@SabotageAndi
Copy link
Contributor

Ok, this method makes no sense.
We could also remove it, because it's only usage is here: https://github.com/techtalk/SpecFlow/blob/master/TechTalk.SpecFlow/Infrastructure/ContainerBuilder.cs#L127
This could be replaced with a specFlowConfiguration.Plugins.

And yes, this can lead to double initialization of Plugins.
The real bug is here: https://github.com/techtalk/SpecFlow/blob/master/TechTalk.SpecFlow/Configuration/AppConfig/AppConfigConfigurationLoader.cs#L115
We are simply adding all plugins the the already loaded configuration. There needs to be a check before adding a new entry.

@vitezp
Copy link
Contributor Author

vitezp commented Apr 23, 2018

Added check which won't allow adding the plugin which is already in the list of plugins to load. For both Json and AppConfig configurations.

@SabotageAndi SabotageAndi merged commit d099aea into SpecFlowOSS:master Apr 25, 2018
@SabotageAndi
Copy link
Contributor

resolves #888

alexvv pushed a commit to alexvv/SpecFlow that referenced this pull request Apr 29, 2018
* Fix return type of GetPlugins method to prevent loading multiple plugins

* added to changelog

* Check if plugin to add is in list of plugins for json and appconfig

* adding unit tests to check loading multiple same plugins
@yesiamtom
Copy link

Nice work, seeing as this is merged to master will this be in the next Specflow release? Sorry if it's obvious, not all that familiar with Github.

@SabotageAndi
Copy link
Contributor

@yesiamtom yes, this will be in the next SpecFlow release. But there is not yet a timeframe when it will get released.

@Hamels
Copy link

Hamels commented May 7, 2018

Is there any news on when the next Specflow version will be released with this fix?

@SabotageAndi
Copy link
Contributor

@Hamels no, but you can use the packages from our CI feed: https://ci.appveyor.com/nuget/specflow-ci

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants