JUnit error java.lang.Exception:No tests found matching

Source: Internet
Author: User

JUnit error java.lang.Exception:No tests found matching

JUnit was recently used in the process of learning spring, but there was a very frustrating error in the middle.

1Java.lang.Exception:No tests found matching [{Exactmatcher:fdisplayname=cdshouldnotbenull], {exactmatcher: Fdisplayname=cdshouldnotbenull (Soundsystem. Cdplayertest)], {Leadingidentifiermatcher:fclassname=soundsystem. Cdplayertest,fleadingidentifier=Cdshouldnotbenull]] From [email protected]2At Org.junit.internal.requests.FilterRequest.getRunner (filterrequest.java:40)3At Org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createFilteredTest (junit4testloader.java:77)4At Org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest (junit4testloader.java:68)5At Org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests (junit4testloader.java:43)6At Org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests (remotetestrunner.java:444)7At Org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests (remotetestrunner.java:675)8At Org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run (remotetestrunner.java:382)9At Org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main (remotetestrunner.java:192)

The code is as follows:

1 Import Staticorg.junit.assert.*;2 3 ImportJavax.annotation.Resource;4 5 Importorg.junit.Test;6 ImportOrg.junit.runner.RunWith;7 Importorg.springframework.test.context.ContextConfiguration;8 ImportOrg.springframework.test.context.junit4.SpringJUnit4ClassRunner;9 Ten@RunWith (Springjunit4classrunner.class) One@ContextConfiguration (classes = Cdplayerconfig.class) A  Public classCdplayertest { -  - @Resource the     PrivateCompactdisc cd; -  - @Test -      Public voidCdshouldnotbenull () { + assertnotnull (CD); -     } +  A}

Carefully check the code should be no problem, the internet looked under, found a lot of friends have also met the problem of the pit dad, finally found the solution is as follows.

Reference Solutions:

In addition to the package that JUnit needs to reference in the code, it involves another jar package if it involves an application context that needs to be created automatically by spring.
Hamcrest-all-1.3.jar
Just introduce this JAR package.
The spring version used by the author is 4.3.5,junit version 4.12.

Reference to the original:
JUnit error java.lang.Exception:No tests found matching

JUnit Error Java.lang.Exception:No tests found matching

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.