-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Let @BeforeEach and @AfterEach work around all the tests from a single TestFactory (or introduce a new similar @Before/@After pair) #694
Comments
Duplicate of #378 ? |
@sormuras: Well, it looks like, sorry for not noticing. However that this issue contains more detailed description as well as motivation :) Maybe they can be somehow merged? |
Lifecycle hooks work around Here is a possible solution : #735 @sbrannen suggested in #378 that beforeEach & afterEach should run around the factory method and around each dynamic tests produced by it. |
Any progress on this topic? |
I ran the given test example and it works as expected with the latest version (5.6.2). That is:
@junit-team, maybe this issue can be closed ? |
Closing due to the above findings and partially as a duplicate of #1643 which was fixed in JUnit Jupiter 5.3.2. |
Overview
JUnit is used not only for pure unit tests (where each unit test should be completely independent), but often also for (some kind of) integration tests. Sometimes it is extremely useful if you may assert some conditions after a bunch of tests have run. The new
@TestFactory
feature would be an excellent place for it if there were a place for addingassert
s after the whole set ofDynamicTest
s have run.Also sometimes there is a need to prepare test data for the whole set of
DynamicTest
s.The documentation says
However, it may be nice either having
@BeforeEach
and@AfterEach
working before and after the whole bunch of dynamic tests called by one@TestFactory
test, or introducing a new pair of@BeforeXXX
and@AfterXXX
annotation for the same purpose.Currently,
@BeforeEach
and@AfterEach
does not run at all.@BeforeAll
and@AfterAll
runs, but they are run only once andAssertionFailedError
s in@AfterAll
are swallowed and not reported.Code example
The following is currently not possible. Some useful use cases can be easily created if the mechanism worked.
The text was updated successfully, but these errors were encountered: