eclipse - 测试不是注释类型
问题描述
在我的Maven项目中,我添加了testng依赖项,如下所示:
<!-- https://mvnrepository.com/artifact/org.testng/testng -->
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>7.1.0</version>
<scope>test</scope>
</dependency>
但是,当我写一个如下的简单测试时,它找不到@Test
:
public class Test{
@Test
public void test() {
}
}
它抱怨Test is not an annotation type
我试图通过以下行手动添加测试:
import org.testng.annotations.Test;
但它再次抱怨:
The import org.testng.annotations.Test conflicts with a type defined in the same file
我已经多次通过 maven 强制更新我的项目,但仍然没有成功。
解决方案
它不起作用,因为您的类名也是“测试”,因此,您必须更改类名,然后只有 @Test 注释才能工作。
推荐阅读
- cpu - CPU 缓存线大小是否可以修改?以及数据如何在缓存块中传输?
- javascript - 获取特定时区的日期
- r - 如何使用多个变量在 tidyverse 中使用扩展函数?
- json - 为什么我的代码没有快速读取我的 JSON 文件?
- javascript - 如何将按钮与输入放在同一行
- sql-server - 在 xml 数据中的列和属性之间连接表
- node.js - Nginx Ingress URL 重写
- c# - 将ZKT指纹设备集成到dotnet core api项目中的问题
- jquery - jQuery验证器不验证所有更新(或者它是正则表达式)
- jquery - Jquery事件委托未触发