Skip to content

[Spring] Do not reuse generic application context between scenarios #1905

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

Merged
merged 1 commit into from
Feb 28, 2020

Conversation

mpkorstanje
Copy link
Contributor

@mpkorstanje mpkorstanje commented Feb 28, 2020

When neither a glue class with a spring context configuration could be found
nor a cucumber.xml file exists cucumber-spring will fall back to a
GenericApplicationContext to facilitate dependency injection.

The current implementation tries to reuse this application context between
scenarios. This requires refreshing the context which can only be done once.
So it's not possible to reuse the GenericApplicationContext and a new one
should be created for each scenario.

Motivation and Context

https://stackoverflow.com/questions/60445228/cucumber-5-0-0-and-springboot-multiple-scenarios-in-one-feature-file

How Has This Been Tested?

Because cucumber.xml and the GenericApplicationContext are fallback methods it is very hard to test these individually. Had to test these manually using:

https://github.com/mpkorstanje/cucumber-spring-1905

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.

When neither a glue class with a spring context configuration could be found
nor a `cucumber.xml` file exists `cucumber-spring` will fall back to a
`GenericApplicationContext` to facilitate dependency injection.

The current implementation tries to reuse this application context between
scenarios. This requires refreshing the context which can only be done once.
So it's not possible to reuse the `GenericApplicationContext` and a new one
should be created for each scenario.
@coveralls
Copy link

Coverage Status

Coverage increased (+0.04%) to 83.057% when pulling 5f850e6 on fix-generic-application-context-cant-re-reused into 60e6380 on master.

@mpkorstanje mpkorstanje marked this pull request as ready for review February 28, 2020 16:04
@mpkorstanje mpkorstanje added this to the 5.x.x milestone Feb 28, 2020
@mpkorstanje mpkorstanje merged commit 3b56c93 into master Feb 28, 2020
@mpkorstanje mpkorstanje deleted the fix-generic-application-context-cant-re-reused branch February 28, 2020 16:23
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.

2 participants