**When I was doing the unit test @test, I suddenly found that the execution could not be done, and the following showed Junit initialization error initializationError!
Notes.
1. test method must be modified with public
2. The return value must be void
3. The method can not have parameters
4. The package can not have the class name Test class
5. Delete the path to the package from the new package, select JUnit4 or JUnit5 switch debugging
6. Remove the @Ignore annotation on the main class, if you add the following failure and do not execute **
package com.test.junit;
import static org.junit.Assert.*;
import org.junit.Ignore;
import org.junit.Test;
@Ignore
public class FirstTest {
String str1 = "===========TEST1===============";
String str2 = "===========TEST2===============";
@Test
public void test1() {
System.out.println(str1);
}
@Test
public void test2() {
System.out.println(str2);
}
**7. Some people say to reduce the version of JUnit, and others say to import other jar packages. Attach the version **
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
<version>1.3</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-library</artifactId>
<version>1.3</version>
<type>pom</type>
</dependency>
**Eclipse users, all know the Ctrl + S save and three clean, maven Update object, object clean and so on,
If it does not work, create a new identical project -> according to the previous content of the exact same import
(project file is small, it is recommended to import manually, do not copy and paste to avoid the previous error) -> run on success **
Read More: