JUnit initializationError(org.junit.runner.manipulation.Filter)错误

今天在用Junit时,出现了一个错误,百度了好长时间,有的说没有写@Test引起的,有的说版本不对应等等,我检查完我的代码,发现都写了,我建的Java project,就写个测试,也不存在版本对应问题,然后搞得就有点懵逼了。

Case02.testGetReference
initializationError(org.junit.runner.manipulation.Filter)
java.lang.Exception: No tests found matching [{ExactMatcher:fDisplayName=testGetReference], {ExactMatcher:fDisplayName=testGetReference(com.wez.jpa01.test.Case02)], {LeadingIdentifierMatcher:fClassName=com.wez.jpa01.test.Case02,fLeadingIdentifier=testGetReference]] from org.junit.internal.requests.ClassRequest@506e6d5e

	at org.junit.internal.requests.FilterRequest.getRunner(FilterRequest.java:40)

	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)
最后找到了原因,原来我把方法写成了 private修饰的了,修改成public问题解决。

@Test
private void testMerge01() {
	// 把临时状态持久化状态
	Customer customer = new Customer();
	customer.setName("张三");
	customer.setAge(22);
	customer.setPhone("13912345678");
	customer.setEmail("[email protected]");
	customer.setBirthday(new Date());
	customer.setCreateTime(new Date());
	
	Customer mergeCustomer = entityManager.merge(customer);
	
	System.out.println("customer:id=" + customer.getId());
	System.out.println("mergeCustomer:id=" + mergeCustomer.getId());
}




你可能感兴趣的:(Junit)