Eclipse JUnit - possible causes of seeing “initializationError” in Eclipse window

后端 未结 25 1210
情深已故
情深已故 2020-12-13 12:35

I know this question is pretty general but I haven\'t found any hints on why this error may show up. What are possible causes of seeing initalizationError in Eclips

相关标签:
25条回答
  • 2020-12-13 12:58

    I just had the same problem and the same message. I was able to get it fixed by importing to the Java Building Path the hamcrest-all-1.3.jar archive. I'm using a JUnit 4.12 version.

    0 讨论(0)
  • 2020-12-13 12:59

    In my case I have changed project name in pom.xml so the new target directory was generated and junit was searching classes in old directory. You need to change directory for JUnit also in Eclipse

    Properties -> Java Build Path -> Source (Default output folder)

    And also check because some of source folders listed in the same window may have former directory name. You need to change them too.

    0 讨论(0)
  • 2020-12-13 12:59

    I had naively added junit-4.12.jar from poi.apache.org to my Build Path in Eclipse. I deleted it (Project, Properties, Java Build Path, Libraries, junit-4.12.jar, Remove) then in my test class allowed Eclipse to "Fix Project Setup" after pressing Ctrl-1. No more problems! :-)

    0 讨论(0)
  • 2020-12-13 13:00

    For me, I mistakenly added a parameter to the test method which caused initialization error.

    0 讨论(0)
  • 2020-12-13 13:02

    Also make sure you have all @Before-, @After- and whatever-JUnit-annotated methods declared as public. I had mine declared as private which caused the issue.

    0 讨论(0)
  • 2020-12-13 13:03

    I got another failure trace, but for future visitors using their favorite search engine:

    For me the problem was that eclipse somehow decided to execute only a single method in my test class (I couldn't figure out why, though). Especially if you did not change anything in your setup, check your run configuration.

    0 讨论(0)
提交回复
热议问题