导入 org.junit.Test 不起作用但是导入之前和之后有效吗?
Importing org.junit.Test does not work however import Before and After works?
当我尝试 import org.junit.Test
时,我遇到了 The import org.junit.Test conflicts with a type defined in the same file
错误。
我可以毫无问题地导入 Before
和 After
。
使用 @Test
注释时,Eclipse 无法识别它,因此不允许我以这种方式导入它。
进口:
import org.junit.Before;
import org.junit.After;
import org.junit.Test;
Maven 依赖项:
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
能保证class文件名不是Test
吗?
因此 将测试 class 重命名为其他 名称应该可行。
结束测试的最佳实践 class 通过 "Test" 词,如 MyServiceTest。
here.
之前曾多次发过类似的问题
当我尝试 import org.junit.Test
时,我遇到了 The import org.junit.Test conflicts with a type defined in the same file
错误。
我可以毫无问题地导入 Before
和 After
。
使用 @Test
注释时,Eclipse 无法识别它,因此不允许我以这种方式导入它。
进口:
import org.junit.Before;
import org.junit.After;
import org.junit.Test;
Maven 依赖项:
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
能保证class文件名不是Test
吗?
因此 将测试 class 重命名为其他 名称应该可行。
结束测试的最佳实践 class 通过 "Test" 词,如 MyServiceTest。
here.