I have my beans reading and writing some data on disk while working and configuring and would like to work with these files during tests.
For example, I would like to prepare some files on disk before context configuration and after of it configuration but before tests.
How to use run some code at these moments?
If you are using
@RunWith(SpringJUnit4ClassRunner.class)
then you could provide a different class, based on Spring's, and override methods to execute what you want before the context is initialized. But normally you can do the setup and tear down in the test itself by using@BeforeClass
and@AfterClass
.