[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
What do you need the per-class life cycle for, exactly? In our JUnit tests some things do carry over from one test method to another; for example, in Plugin[UI] tests we sometimes use @BeforeClass methods for global config, iirc.
> Am 23.05.2019 um 18:49 schrieb Jens von Pilgrim <developer@xxxxxxxxx>:
>
>
> Dear Colleagues,
>
> I’m a bit confused… probably easy to solve for you.
>
> I haven’t worked with “plain” JUnit for a long time, since we always use the Xtext runner and stuff like that. So I totally forgot the default test life cycle: JUnit creates a new test instance per test method. This is also not changed by our runners, is it? Somehow I thought that we use a per class life cycle, but this is not the case.
>
> With JUnit 5, it is easy to introduce such a life cylce (with annotation @TestInstance(Lifecycle.PER_CLASS)). This is new in JUnit 5, I haven't found this in JUnit 4.
> Now I have several questions:
>
> 1. Would it make sense to use JUnit 5 instead of 4?
> 2. If we would like to use JUnit 5 — how do we configure that? I have only found JUnit 4 in our target platform and I’m not quite sure how to set that up — we urgently need more documentation about the target platform. Or did I only miss it?
> 3. Would it make sense to use the Lifecycle.PER_CLASS, as e.g. the dependency injection is performed only once (and some injected things are not singletons)? And many of our tests seem to be isolated anyway, so it would speed up things it we wouldn’t need to create a new test instance for each test. Any ideas about performance improvement? (I wasn’t able to test it since I wasn’t able to replace JUnit 4 with 5)
>
> Cheers,
> Jens
> _______________________________________________
> n4js-dev mailing list
> n4js-dev@xxxxxxxxxxx
> To change your delivery options, retrieve your password, or unsubscribe from this list, visit
> https://www.eclipse.org/mailman/listinfo/n4js-dev