-
-
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
Nested PER_METHOD inside PER_CLASS should call TestInstanceFactory for enclosing class #1566
Comments
Thanks for raising this issue before 5.3 GA! I am not yet certain if it's a "bug"; however, I am going to label it as a bug for the time being to ensure that it gets looked at with high priority. |
OK. I took at look at the code in question. This is the expected behavior. A Thus, in your example, Please note that this behavior is specific to the semantics for I am therefore closing this issue as "works as designed". |
Thank you, but that is unexpected, so inner classes may not override the Lifecycle, or only if the outer is PER CLASS? Shouldn't this lead to an error, since the results are unexpected? |
I suppose whether it's expected behavior or not is debatable, but that is the behavior the JUnit Team decided on when the feature was implemented. A A The general rule is that each test class (whether top-level, nested, or a subclass) decides for itself what its lifecycle mode should be. The only form of inheritance with regard to lifecycle modes is that subclasses inherit the mode from their parent class by default. |
Just to clarify: Btw. Thank you very much for the quick responses. |
That's correct.
They should be if there is a
You're welcome. |
Currently I am trying to integrate JUnit 5.3.0-RC1 into a Weld-SE-Test framework,
ejb-cdi-unit
.The first solution based on JUnit 5.2.0 available in
ejb-cdi-unit:1.1.15
restricts the TestInstance-Classes somewhat concerning CDI. I can only allow@Inject
. That helps already very much, but see this note.Now while trying to implement the
TestInstanceFactory
to avoid the aforementioned restrictions, I encounter problems with this example.You can see a
ServiceTest5
test class working with lifecyclePER_CLASS
and two nested test classes of which one is working with lifecyclePER_METHOD
.The inner classes are currently disabled to avoid email notifications from Travis CI.
I would expect, that before the method
ServiceTest5.WhenSomeEntitiesInDbExist.cantReadTestDataUsingServiceInRequiredNew()
is called, that a completely new instance ofServiceTest5
would be created using theTestInstanceFactory
implemented inJUnit5Extension
, since the nested inner classWhenSomeEntitiesInDbExist
has LifecyclePER_METHOD
.That is not the case.
Is that by design or a bug in the release candidate?
The text was updated successfully, but these errors were encountered: