导入 org.testng.annotations.*; 无法解决

-1 testng selenium annotations

我已经成功安装了 TestNG 并在 eclipse (4.9.0) 中进行了确认。但是,在创建没有主类的基本类时,我在注释 @Test 处收到错误。即使导入测试注释包后,包上也存在错误。并且错误表明无法解决。 在此输入图像描述

小智 6

如果您使用 Maven 项目更改范围测试并添加范围编译 -

<!-- https://mvnrepository.com/artifact/org.testng/testng -->
        <dependency>
            <groupId>org.testng</groupId>
            <artifactId> testng </artifactId>
            <version>6.14.3</version>
            <scope>compile</scope>  //replace test to compile 
        </dependency>
Run Code Online (Sandbox Code Playgroud)