When I running my junit test, console print this Excpetion:
java.lang.NullPointerException
at org.eclipse.jdt.internal.junit4.runner.SubForestFilter.shouldRun(SubForestFilter.java:81)
at org.junit.internal.runners.JUnit4ClassRunner.filter(JUnit4ClassRunner.java:110)
at org.junit.runner.manipulation.Filter.apply(Filter.java:47)
at org.junit.internal.requests.FilterRequest.getRunner(FilterRequest.java:34)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createFilteredTest(JUnit4TestLoader.java:77)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:68)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:43)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:444)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
And the Base test object like this
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.transaction.TransactionConfiguration;
import org.springframework.transaction.annotation.Transactional;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {
"classpath*:config/spring/appcontext-*.xml",
"classpath*:config/sqlmap/*.xml"
})
@TransactionConfiguration(defaultRollback = false)
@Transactional
public abstract class AbstractTestObject {
static {
//DOMConfigurator.configure("target/classes/log/log4j.xml");
}
}
And the JUnit Method like this:
public class StaffInfoServiceImplTest extends AbstractTestObject{
@Autowired
StaffInfoServiceImpl service;
@Test
public void insertTest() {
StaffInfo bo = new StaffInfo();
bo.setEmail("a@b.com");
bo.setEntId(1);
bo.setEntStaffNum("000XXXX");
bo.setName("julia");
bo.setPhone("00000000");
bo.setSerialNum("SD12233KSRONDU189342ND");
bo.setSuperior(2321);
bo.setDepartment("Sale");
bo.setSingleCredit(BigDecimal.valueOf(100));
bo.setMonthlyCredit(BigDecimal.valueOf(10000));
SLTContext c = new SLTContext();
c.setOperator("0000001");
service.insertStaffInfo(bo, c);
}
}
My project is Java EE project, using maven to manage lib, using spring manage beans.
My Develop Environment is:
Mac OS X Yosetime 10.10.4
Eclipse Java EE IDE for Web Developers(Version: Mars Release (4.5.0))
Maven plugin(install from Eclipse->Install New Software)
I guess this is a conflict between eclipse junit and project junit config, but I'm not sure.
How to solve the problem, thanks.