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

后端 未结 25 1207
情深已故
情深已故 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:39

    For me, it was due to the "return type" of the test method. It should be "void"

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

    For me it was a silly mistake. I inadvertently set the test as private instead of public:

    @Test
    private void thisTestWasCausingProblems() {
    ...
    }
    

    it should have been

    @Test
    public void thisTestIsOK() {
    ...
    }
    
    0 讨论(0)
  • 2020-12-13 12:40

    My problem was that my parent class had no @Test methodes. I used there only some utilities. When I declared it abstract it works.

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

    If you're using the xtend language (or some other JVM lang with type inference) and haven't explicitly defined the return type then it may be set to a non-void type because of the last expression, which will make JUnit fail.

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

    I had the same problem, the solution for me is the following.

    I had only install the junit.jar file from the web, but this library related with the hacrest-core.jar When I downloaded the hacrest-core.jar file and added it in my project everything works fine.

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

    Just if this helps, I was using Junit5 but the @RunWith(SpringRunner.class) was pointing towards import org.springframework.test.context.junit4.SpringRunner, which was messing around with things and hence was giving the initialization error. I fixed this and it worked.

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