Junit test error

      A question about the junit test class I accidentally discovered today. In general, you either import the junit package or use maven to configure dependencies directly, etc. When the test class inherits the TestCase class, we generally write our own test methods directly, and name them casually. Then I found that the error "method 'initializationError' not found.Opening the test class" was reported.



 

      The most direct solution to this problem is that the naming rules must meet the requirements of junit. As long as your method name prefix starts with test*, it can pass, and you will not encounter this problem!

      As for the reason, the custom initial method in the junit source code is matched according to the prefix name. If you can't find the beginning of test, you can't enter the initialization, and then you will get this error!

      If you go to the method named public void myTest(){...}, and then you run it directly, sorry, it's wrong!


    
 

      Then you change the method name to public void testMyTest(){...} and it will work! Unless you configure it, follow the junit naming rules!


     
 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326584131&siteId=291194637