Reputation: 901
How do I get ApplicationContext
object so that i can use it in my code, after setting context using@ContextConfiguration
.
My test class extends AbstractTransactionalJUnit4SpringContextTests
.
Upvotes: 4
Views: 4481
Reputation: 12175
I generaly just inject a copy of the Application Context into the unit test:
@Autowired
ApplicationContext context;
Upvotes: 10
Reputation: 403441
AbstractTransactionalJUnit4SpringContextTests
extends AbstractJUnit4SpringContextTests
, which has a protected applicationContext
field. Your test class can just use that.
Upvotes: 5