java.lang.Exception:找不到匹配的测试

时间:2015-12-03 03:28:38

标签: java junit

我的测试课程如下:

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.AbstractJUnit4SpringContextTests;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import com.hepeihui.service.UserService;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations={"/beans.xml"})
public class UserTest extends AbstractJUnit4SpringContextTests {

    @Autowired
    private UserService userService;

    @Test
    public void addUserTest(){
        System.out.println("test");
    }
}

当我尝试使用JUnit运行它时,我得到一个例外:

java.lang.Exception: No tests found matching [{ExactMatcher:fDisplayName=addUserTest], {ExactMatcher:fDisplayName=addUserTest(com.hepeihui.test.UserTest)], {LeadingIdentifierMatcher:fClassName=com.hepeihui.test.UserTest,fLeadingIdentifier=addUserTest]] from org.junit.internal.requests.ClassRequest@17a83597
    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)

enter image description here

如何解决此错误并让测试再次运行?

1 个答案:

答案 0 :(得分:1)

aopaliance.jar遗失了所以我添加了它。

问题现已解决。