Support for @BeforeAll annotation.
If you have a project with a lot of test classes and test methods and if your context object is complex this can improve the speed of test execution.
Otherwise, the context object or some other objects are created for each test method.
currently @BeforeAll is not supported because if the context is not "immutable" - each unit test can write data to the repository, and thus the next unit test in the same class starts with a "dirty" repository which may impact the reproducibility of the tests.
but if you are aware of this problems and make sure this does not happen (e.g. doing writing to the repository only in the BeforeAll method) it might by useful to have @BeforeAll support. just do not see it as "silver bullet" to solve all performance problems by switching all @Before methods to @BeforeAll.
i will think about it and make some experiments if i find a bit time the next weeks. PRs welcome
we might think about some way to "reset" a context object to it's initial state without the need to completely recreate it - but this may be not so easy as it not only affects the repository, but also OSGi services and other thinks registered via the context.
Hi Stefan, I completely agree with what you said in your first comment. In our case the boost in execution time is 200-250% (measured by calling all test cases from only one test method on a class level). So I am fine with leaving it up to developers to decide weather they can reuse the context object on class level or not.
Regarding your second comments, that would be really nice to have, but also just having a shared object would be a great start.