5

My test class is below:

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");
    }
}

When I attempt to run it with JUnit, I get an exception:

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

How can I resolve this error and get the tests running again?

7
  • can you rename your test case to be testAddUser instead of addUserTest. I want to see if adding the word test at the beginning make any difference.
    – Raf
    Commented Dec 3, 2015 at 3:34
  • You will most probably find an answer here stackoverflow.com/questions/2332832/…
    – Raf
    Commented Dec 3, 2015 at 3:43
  • Thank you very much.When i rename my test case to be testAddUser ,it doesn't make any difference. At last ,I found my project loss a jar.
    – feibabm
    Commented Dec 11, 2015 at 6:13
  • 1
    Good, you can write an answer for your own question describing how you solved it. You can then mark it as accepted.
    – Raf
    Commented Dec 11, 2015 at 9:04
  • I am sorry i don't know how to mark it as accepted.Could you tell me,Thanks.
    – feibabm
    Commented Dec 14, 2015 at 2:59

1 Answer 1

1

aopaliance.jar was missing so I added it.

The issue is now resolved.

Not the answer you're looking for? Browse other questions tagged or ask your own question.