无法在IntelliJ中找到TestNG

时间:2017-01-29 14:31:14

标签: java maven intellij-idea testng ubuntu-16.04

我有appspot.com。我有Ubuntu Studio 16.10 Build#IC-163.10154.41,建于2016年12月21日

IntelliJ IDEA 2016.3.2

JRE: 1.8.0_112-release-408-b6 amd64 服务器VM由JetBrains s.r.o提供 我用JVM: OpenJDK 64-Bit 我在Apache Maven 3.3.9

中使用了以下内容
pom.xml

我转到我的项目目录并运行<?xml version="1.0" encoding="UTF-8"?> <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> <repositories> <repository> <id>jcenter</id> <name>bintray</name> <url>http://jcenter.bintray.com</url> </repository> </repositories> <groupId>test</groupId> <artifactId>myproject</artifactId> <version>1.0-SNAPSHOT</version> <properties> <project.build.sourceencoding>UTF-8</project.build.sourceencoding> </properties> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.12</version> </dependency> <!-- https://mvnrepository.com/artifact/org.testng/testng --> <dependency> <groupId>org.testng</groupId> <artifactId>testng</artifactId> <version>6.9.12</version> <scope>test</scope> </dependency> <dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-java</artifactId> <version>3.0.1</version> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.1</version> <configuration> <source>1.8</source> <target>1.8</target> </configuration> </plugin> </plugins> </build> </project> 我还检查了另一篇文章,其中建议右键单击项目文件夹并选择Maven-&gt;重新进口,但该选项不可用。 我得到了mvn clean install。虽然外部库显示出junit存在。我从未见过TestNG。它在日志中说..下载BUILD Success 当我使用testng-6.9.12.jar时,我得到的只是返回命令提示符。 在编辑器中,我尝试导入org.testng。*;导入语句在我写完后就被删除了。我在locate testng-6.9.12.jar Intellij上使用vim kinda安排 我也试过从jcentral和maven repositiories下载,但无济于事。

我无法在外部库Ubuntu 16.10junit

中看到TestNG

1 个答案:

答案 0 :(得分:0)

可能是因为Maven在Maven中心找不到6.9.12(因为你的pom文件没有任何<repository>标签,maven会尝试仅在repo1.maven.org/maven2/中查找你的工件)。

我尝试搜索here但找不到版本6.9.12

最新发布的TestNG版本为6.10。因此,请将<version>中的<dependency>标记替换为6.10,然后重试。这应该照顾它。

<scope>test</scope>只是告诉Maven的一种便捷方式,只有在运行测试时才需要解析TestNG。 compile的默认范围告诉TestNG在编译代码本身时(通常为src/main/java)可以使工件可用。它与你在这里遇到的问题没有任何关系(就我所知而言)