在 maven 依赖项中添加 TestNG 后,TestNG 在 selenium 中不可用 (pom.xml)
TestNG not available in selenium after adding TestNG in maven dependency (pom.xml)
我无法在 TestNG 框架下执行我的代码。我在 Eclipse 的范围内添加了依赖项并编译了 TestNG。请让我知道如何显示 TestNG。我可以使用 JUnit 执行但不能使用 TestNG。
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>SignUpAccount</groupId>
<artifactId>SignUpAccount</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>SignUpAccount</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.14.3</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId> selenium-java </artifactId>
<version>3.141.59</version>
</dependency>
</dependencies>
</project>
安装 TestNG 插件然后重试,如果您是 运行 来自 Eclipse 的,单独添加 TestNG 依赖项将不起作用。
你需要在你的eclipse中安装testng,然后你才能看到testng和它的注解。安装请参考以下link:
http://testng.org/doc/download.html
如果你使用 Maven 依赖需要改变范围 test 到 compile
<!-- https://mvnrepository.com/artifact/org.testng/testng -->
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.14.3</version>
<scope>compile</scope> // remove test and add this line
</dependency>
我无法在 TestNG 框架下执行我的代码。我在 Eclipse 的范围内添加了依赖项并编译了 TestNG。请让我知道如何显示 TestNG。我可以使用 JUnit 执行但不能使用 TestNG。
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>SignUpAccount</groupId>
<artifactId>SignUpAccount</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>SignUpAccount</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.14.3</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId> selenium-java </artifactId>
<version>3.141.59</version>
</dependency>
</dependencies>
</project>
安装 TestNG 插件然后重试,如果您是 运行 来自 Eclipse 的,单独添加 TestNG 依赖项将不起作用。
你需要在你的eclipse中安装testng,然后你才能看到testng和它的注解。安装请参考以下link: http://testng.org/doc/download.html
如果你使用 Maven 依赖需要改变范围 test 到 compile
<!-- https://mvnrepository.com/artifact/org.testng/testng -->
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.14.3</version>
<scope>compile</scope> // remove test and add this line
</dependency>