Record the use of Junit to report errors and solutions
(1)Test is not an annotation type
I won't say much about the error description. Tell me about the background of my environment so that I can better record the scene where this problem occurs. I recently learned about shiro, because of the work requirements, to test a piece of code, so I created a small project named Test class, the previous test was executed using the main method without any problems.
Today, I want to test the permission function of shiro, and I want to use Junit to test it. I was lazy and added a method to the Test class to test, and the result reported the following error:
At first glance, it shouldn't be, JAR is dripping. Later, I found that the name of the Test class created is the same as the name of the annotation @Test.
Solution:
The class name of the test cannot be the same as @Test
(2)junit.framework.AssertionFailedError: No tests found in xxxxx
The test code is as follows:
The error message at runtime is as follows:
junit.framework.AssertionFailedError: No tests found in com.stydy.shiro.TestShiro at junit.framework.Assert.fail(Assert.java:57) at junit.framework.TestCase.fail(TestCase.java:227) at junit.framework.TestSuite$1.runTest(TestSuite.java:97) at junit.framework.TestCase.runBare(TestCase.java:141) at junit.framework.TestResult$1.protect(TestResult.java:122) at junit.framework.TestResult.runProtected(TestResult.java:142) at junit.framework.TestResult.run(TestResult.java:125) at junit.framework.TestCase.run(TestCase.java:129) at junit.framework.TestSuite.runTest(TestSuite.java:252) at junit.framework.TestSuite.run(TestSuite.java:247) at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:86) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
The reason is that the red words in the picture indicate that the first letter of the method is capitalized.
Solution:
Capitalize and lowercase method
------------------------------------Take a note----------- ----------------------------