17
JUnit测试在Eclipse中通过,但在Maven Surefire中失败
我已经使用JUnit 4和spring-test库编写了一些JUnit测试。当我在Eclipse中运行测试时,可以正常运行并通过。但是,当我使用Maven运行它们时(在构建过程中),它们无法给出与Spring相关的错误。我不确定是什么引起了问题,JUnit,Surefire或Spring。这是我的测试代码,spring配置以及我从Maven获得的异常: PersonServiceTest.java package com.xyz.person.test; import static com.xyz.person.util.FjUtil.toFjList; import static junit.framework.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import java.util.List; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.AbstractTransactionalJUnit4SpringContextTests; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.transaction.TransactionConfiguration; import org.springframework.transaction.annotation.Transactional; import com.xyz.person.bo.Person; import com.xyz.person.bs.PersonService; import fj.Effect; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { "classpath*:personservice-test.xml" }) @TransactionConfiguration(transactionManager = "transactionManager", defaultRollback = false) …