-
-
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
Not all methods of Springs TestContextManager
are invoked.
#2572
Labels
Milestone
Comments
mpkorstanje
added a commit
that referenced
this issue
Dec 11, 2022
To make writing tests with Spring easier Spring provides a `TestContextManager`. This classes provides call backs for various `TestExecutionListeners`. These are then used by various extensions such as the `MockitoTestExecutionListener` which injects `@MockBeans` into test instances. When all methods are not invoked this leads to problems such as (#2654,#2655,#2656) While this was initially (#1470) not a problem, it appears that various listener implementations have started to assume that all methods would be invoked. Closes: #2655 Fixes: #2654, #2572
mpkorstanje
added a commit
that referenced
this issue
Dec 11, 2022
To make writing tests with Spring easier Spring provides a `TestContextManager`. This classes provides call backs for various `TestExecutionListeners`. These are then used by various extensions such as the `MockitoTestExecutionListener` which injects `@MockBeans` into test instances. When all methods are not invoked this leads to problems such as (#2654,#2655,#2656) While this was initially (#1470) not a problem, it appears that various listener implementations have started to assume that all methods would be invoked. Closes: #2655 Fixes: #2654, #2572
mpkorstanje
added a commit
that referenced
this issue
Dec 11, 2022
To make writing tests with Spring easier Spring provides a `TestContextManager`. This classes provides call backs for various `TestExecutionListeners`. These are then used by various extensions such as the `MockitoTestExecutionListener` which injects `@MockBeans` into test instances. When all methods are not invoked this leads to problems such as (#2654,#2655,#2656) While this was initially (#1470) not a problem, it appears that various listener implementations have started to assume that all methods would be invoked. Closes: #2655 Fixes: #2654, #2572
7 tasks
mpkorstanje
added a commit
that referenced
this issue
Dec 11, 2022
To make writing tests with Spring easier Spring provides a `TestContextManager`. This classes provides call backs for various `TestExecutionListeners`. These are then used by various extensions such as the `MockitoTestExecutionListener` which injects `@MockBeans` into test instances. When all methods are not invoked this leads to problems such as (#2654,#2655,#2656) While this was initially (#1470) not a problem, it appears that various listener implementations have started to assume that all methods would be invoked. Closes: #2655 Fixes: #2654, #2572
mpkorstanje
added a commit
that referenced
this issue
Dec 11, 2022
To make writing tests with Spring easier Spring provides a `TestContextManager`. This classes provides call backs for various `TestExecutionListeners`. These are then used by various extensions such as the `MockitoTestExecutionListener` which injects `@MockBeans` into test instances. When all methods are not invoked this leads to problems such as (#2654,#2655,#2656) While this was initially (#1470) not a problem, it appears that various listener implementations have started to assume that all methods would be invoked. Closes: #2655 Fixes: #2654, #2572
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in two months if no further activity occurs. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
π What did you see?
Not all methods of Springs
TestContextManager
are invoked.β What did you expect to see?
To facilitate integration testing frameworks such as Cucumber, Spring provides a
TestContextManager
to help setup a Spring application for tests. However currently not all methods are invoked, or invoked with partial information.Cucumber currently does not invoke
test instance preparation
,before test execution
,after test execution
at all. Cucumber can not invoke these methods with the correct semantics because theObjectFactory
is not aware of the test execution and can not execute anything between the execution of before scenario hooks and step definitions. Further more, theObjectFactory
is not aware of aware of the result of any scenario and can not pass any exceptions thrown to the after- methods.ποΈ What would be a possible solution?
After #2174 it should be possible to refactor Cucumbers internals such that instead of providing providing
Backend
andObjectFactory
extension points, we can provide individual extension points equivalent to JUnit Jupiters:BeforeAllCallback
,AfterAllCallback
,TestInstancePostProcessor
,BeforeEachCallback
,AfterEachCallback
,BeforeTestExecutionCallback
andAfterTestExecutionCallback
. To ensure these callbacks can transfer state an equivalent to JUnit JupitersExtensionContext
would also have to be provided. Specifically theObjectFactory
could be replaced with theTestInstanceFactory
andBackend
could be reduced to only the discovery of glue definitions.Additional benefits of closely following this pattern would be the relative ease by which we can re-implement existing extensions from JUnit JUpiter for Cucumber. We can benefit from a larger ecosystem here.
Do note: A 1-to-1 adoption of JUnit Jupiters extension system is not possible. JUnit Jupiter assumes that there is a single test class, test instance, and method. Cucumber generally has multiple.
The text was updated successfully, but these errors were encountered: