How to access Spring context in jUnit tests annotated with @RunWith and @ContextConfiguration?

前端 未结 4 1810
萌比男神i
萌比男神i 2020-12-08 03:55

I have following test class

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {\"/services-test-config.xml\"})
public class MySericeT         


        
4条回答
  •  清歌不尽
    2020-12-08 04:37

    If your test class extends the Spring JUnit classes
    (e.g., AbstractTransactionalJUnit4SpringContextTests or any other class that extends AbstractSpringContextTests), you can access the app context by calling the getContext() method.
    Check out the javadocs for the package org.springframework.test.

提交回复
热议问题