用junit4进行测试时出现initializationError问题,求助大神

代码如下:
import java.io.Serializable;
import java.util.List;
import javax.annotation.Resource;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import cn.itcast.pojo.Department;
import cn.itcast.service.IDepartmentService;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("/bean.xml")

public class Test_DepartmentService{

@Resource
private IDepartmentService departmentService;

@Test
public void save(Department department) {

}

@Test
public void update(Department department) {

}

@Test
public void delete() {
    System.out.println(departmentService);
    departmentService.delete(1L);
}

@Test
public Department findById(Serializable id) {       
    return null;
}

@Test
public List<Department> getAll() {
    return null;
}

}
Failure Trabe代码如下:
java.lang.Exception: No tests found matching [{ExactMatcher:fDisplayName=delete], {ExactMatcher:fDisplayName=delete(junit.test.service.Test_DepartmentService)], {LeadingIdentifierMatcher:fClassName=junit.test.service.Test_DepartmentService,fLeadingIdentifier=delete]] from org.junit.internal.requests.ClassRequest@64b8f8f4

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)

)
按照网上教程导入hamrest-core-1.3.rc2.jar和hamrest-library-1.3.rc2.jar之后依然没办法进行Junit测试

2个回答

把@Source() 去掉 如果@Test注解的方法是静态的也会报这样的错误

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问