简体   繁体   中英

Junit Spring initialization is not working

When I run the below test, It just hangs. I took a thread dump and fount out that its blocking in SpringJunit4ClassRunner line 91 where there is this line

private static final Log logger = 
LogFactory.getLog(SpringJUnit4ClassRunner.class);

=========My Test Program ==============================
@RunWith(SpringJUnit4ClassRunner.class)
//@ContextConfiguration(locations={"/context-test.xml"})
public class ClassTest{

//    @Autowired
//    ClassName bean;

@Test
public void testConfig() {
    System.out.println("hello");
    //       System.out.println(bean.getConnectTimeout());
    System.out.println("end");
}

}

Is anyone facing the same problem and how did you fix this?

Found out that JMockito was sharing the commons-logging library which the spring-context uses and jMockito was not initializing it which in turn caused this program to hang.

Removing the Jmockito dependency made it work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM