I have multiple interconnected beans in configuration and would like to test various operation after global state changed.
For example, I have execute()
of some bean, after which many beans are changed.
Currently I put all check inside testExecute()
method, but this method becomes huge and non-separated.
Is it possible to execute execute()
before entire class run, i.e. just after context was initialized?
@BeforeClass
methods should be static, while I need to have context already initialized and autowired. Is it possible?
UPDATE
Note, that running "before class" in Spring environment should also include control of when context initialization occurs. I.e. one may want to run some code before context initialized and after context initialized (but both cases before class).
UPDATE 2
Also, Spring & JUnit allows @DirtiesContext
annotation, which means that context will be initialized again. In such cases, "before" methods should be called again and also in the appropriate order.