首页 > 解决方案 > 类的重复注释:接口 org.testng.annotations。之前方法

问题描述

我是 Selenium Java 的新手。运行 java 类时,它显示以下错误:

[RemoteTestNG] 检测到 TestNG 版本 6.14.3 java.lang.annotation.AnnotationFormatError: Duplicate annotation for class: interface org.testng.annotations.BeforeMethod: @org.testng.annotations.BeforeMethod(inheritGroups=true, dependsOnGroups=[], dependsOnMethods =[],firstTimeOnly=false,groups=[],description=,alwaysRun=false,

什么Duplicate annotation意思,我应该在哪里调试?

环境:Eclipse Neon、Mac、Maven 项目、TestNg 框架。

标签: javaseleniumtestng

解决方案


我刚刚想通了。在我错误打印的“测试基类”之一中

@BeforeMethod 标记两次,因此在运行 java 类时,它会显示上述错误。删除额外的@BeforeMethod 标签,解决了这个问题。


推荐阅读