The typical exmaple is:
@ContextConfiguration(locations = {
"classpath:someITTest-mock.xml",
"classpath:someITTest-context.xml",
"classpath:commons.xml"})
@Transactional
@RunWith(SpringJUnit4ClassRunner.class)
public class SomeITTest {
//...
}
I am finding the way to recreate mocks during tests. The obvious way to use DirtiesContext But it results to recreate all contexts, when only mock context should be recreated.
Here is several notes:
- Context with mock seems to be loaded first, because other depended context do not have such beans.
- When mocks are created and injected into depended context, it is probably impossible to cache/reuse depended context.
So is there a way to recreate spring context where mocks are created, but leave other context cached?
Aucun commentaire:
Enregistrer un commentaire