![](/img/trans.png)
[英]Maven failed JUnit Spring controller test but in eclipse works fine
[英]JUnit Test cases failing while running using Maven but works with Eclipse
我有一個Junit測試用例,如果我使用Maven運行,它將無法正常工作。 但是,當我使用Eclipse運行時,相同的測試用例也可以工作。 我的Junit課程就是這樣。
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:/test-config.xml"} )
public class TestDaoImpl {
private final static Logger logger = Logger.getLogger(TestDaoImpl.class);
@Autowired
private MyDaoImpl myDao;
@Test
public void testMyDao() throws Exception {
logger.info("Called testMyDao()================");
// here myDao is null and throwing NullPointerException in sunfire log.
// But this works when I run using Eclipse.
List<MyObj> objList = myDao.getList();
}
@Test
public void testMyCode() throws Exception {
logger.info("Called testMyCode()================");
// this test case works with Maven
List<MyObj> objList = MyClass.getList();
}
}
sunfire插件丟失。 添加后,它開始工作。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.