-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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 the glue class autowiring, transaction and cucumber-glue scope issues of the spring module #711
Merged
paoloambrosio
merged 15 commits into
cucumber:master
from
brasmusson:spring-stepdef-injection-error
Jun 30, 2014
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
6f6aba0
Disclose that spring step def injection does not work
brasmusson 54d04f7
Set the cucumber-glue.xml context as parent to the test context
brasmusson 8da3bb1
Add transaction test to the spring module
brasmusson 6a5814e
Make sure dirtyCukes.feature fails if the context is reused
brasmusson 13640b2
Use the same class to create all TestContextManagers
brasmusson 61c9d58
Fail if no glue class with spring annotation is found
brasmusson 73039ae
Fail if glue classes with different spring annotations are found
brasmusson e53331e
Only create one spring TestContextManager
brasmusson 17aef31
Updated RunCukesTest in the example spring-txn with new hook location.
mmalmeida ebf0da7
Make example/spring-txn fail if transactions are not used
brasmusson 8ac8f43
Test step def injection in the oposite direction.
brasmusson f895b9e
Register the glue classes in the TestContextManager's context
brasmusson 5cad5cf
Restructure the test class packages for the spring module
brasmusson de2eeaf
Improve error message when no spring annotation class is found
brasmusson 4879f9e
Handle that @ContextConfiguration annotation is not used
brasmusson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
examples/spring-txn/src/test/resources/cucumber/examples/spring/txn/see_messages.feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
@txn | ||
Feature: See Messages | ||
|
||
Scenario: See another user's messages | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 0 additions & 18 deletions
18
spring/src/main/resources/cucumber/runtime/java/spring/cucumber-glue.xml
This file was deleted.
Oops, something went wrong.
17 changes: 0 additions & 17 deletions
17
spring/src/test/java/cucumber/runtime/java/spring/NonSpringGlue.java
This file was deleted.
Oops, something went wrong.
8 changes: 0 additions & 8 deletions
8
spring/src/test/java/cucumber/runtime/java/spring/RunCukesTest.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we want to fail if glue classes with different Spring annotations are found?
In real life we often see Spring-y tests that define slightly different contexts and are more or less independent from each other. AFAIU when similar independent step definitions will be loaded by the same runtime (e.g. one JUnit runner class), we'll throw an error in this PR. I'm afraid real users might find that counter-intuitive and inconvenient.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only one Spring test is loaded during each run, but more than one Cucumber step definition is loaded for each scenario. I agree with @brasmusson we should allow only one Spring context. @mgurov while I see advantages in injecting a specific Spring context in JUnit tests, I'd like to see an example of where this is needed in Cucumber. Supporting multiple context is controversial enough to deserve a separate entry in the issue tracker and a deeper discussion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also in Cucumber-JvM v1.1.3 only one spring context was allowed, then it was hardcoded that the file
cucumber.xml
on the classpath defined the spring context.From an implementation point of view, probable the biggest problem with allowing multiple context is to find out in which the SpringTransactionHooks need to be in to find the bean implementing the PlatformTransactionManager it needs to do its job.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@paoloambrosio in general I agree that less contexts is better but IMHO it is not the mission of cucumber-jvm to force one or another spring practice.
I'm a bit concerned about the proliferation of the
RunCukesTest.java
s that we see even in this change, but if you guys do not see an issue with that then fine with me.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mgurov I just do not see how it should work in detail. In which of the several context should the SpringTransactionHooks class be put (so it finds the PlatformTransactionManager it needs)? Or should it be forbidden to have more than one context if you use transactions?
And what about glue classes without context annotations, in which context should they be put? Or should we require context annotations on all glue classes (that use spring)? I have got the impression that the requirement that every glue class (that use spring) must have an context annotation is one of the problems the v1.1.6.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@brasmusson yes, that can be tricky with the
TestContextManager
. One of the options could be to (partially) reimplement it for our needs and build the context (or hierarchy of contexts) ourself. But maybe the current solution would be good enough as long as heavy spring module users do not complain.