Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
与Maven一起运行POM_Maven_Testng_Pom.xml - Fatal编程技术网

与Maven一起运行POM

与Maven一起运行POM,maven,testng,pom.xml,Maven,Testng,Pom.xml,我正在通过maven运行pom,并得到以下错误。波姆看起来不错。当使用testng运行时,它成功构建。有人能帮我吗 编辑 testng.xml: <?xml version="1.0" encoding="UTF-8"?> <suite name = "Automation Test"> <test name = "Smoke Test"> <classes> <class name = "Prem

我正在通过maven运行pom,并得到以下错误。波姆看起来不错。当使用testng运行时,它成功构建。有人能帮我吗


编辑

testng.xml:

<?xml version="1.0" encoding="UTF-8"?>

<suite name = "Automation Test">
    <test name = "Smoke Test">
      <classes>
          <class name = "Premiums.Insurance"/>
      </classes>       
  </test>    
</suite>

pom.xml:

<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>Insurance</groupId>
  <artifactId>Premiums</artifactId>
  <version>1</version>
  <packaging>jar</packaging>
  <name>Premiums</name>
  <url>http://maven.apache.org</url>
  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>
  <profiles>
    <profile>
      <id>Insurance</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.19.1</version>
            <configuration>
              <suiteXmlFiles>
                <suiteXmlFile>Insurance.xml</suiteXmlFile>
              </suiteXmlFiles>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
  <dependencies>
    <dependency>
      <groupId>org.seleniumhq.selenium</groupId>
      <artifactId>selenium-java</artifactId>
      <version>3.3.1</version>
    </dependency>
    <dependency>
      <groupId>io.appium</groupId>
      <artifactId>java-client</artifactId>
      <version>2.1.0</version>
    </dependency>
    <dependency>
      <groupId>org.testng</groupId>
      <artifactId>testng</artifactId>
      <version>6.7</version>
    </dependency>
  </dependencies>
</project>

4.0.0
保险
保险费
1.
罐子
保险费
http://maven.apache.org
UTF-8
保险
org.apache.maven.plugins
maven surefire插件
2.19.1
Insurance.xml
org.seleniumhq.selenium
硒爪哇
3.3.1
木卫一
java客户端
2.1.0
org.testng
testng
6.7

您必须使用这些依赖项和插件

<dependency>
     <groupId>org.testng</groupId>
     <artifactId>testng</artifactId>
     <version>6.8.8</version>
 </dependency>

org.testng
testng
6.8.8


org.apache.maven.plugins
maven编译器插件
1.8
1.8

对于要作为testng测试运行的内容,应该使用@test annotations对其进行注释。或者,如果您以编程方式调用testng,那么您可以使用main方法创建一个套件

在您粘贴的代码中,只有一个main方法,这对testng没有任何意义


添加testng注释,重命名方法,使其听起来更像测试,并阅读一些基础知识

您可以分享您的代码testng.xml和pom.xml吗?6.7是一个非常旧的testng版本。是否可以使用较新的版本重试,并告诉我们它是否有效?请不要创建答案以向您的问题添加信息。答案应仅包含对您的问题的答案。如果你想对你的问题进行添加/更改,那么你可以修改它。我已经添加了@test注释。它在我执行mvn测试并成功构建时运行,但在我执行mvn测试时失败,错误为“fork进程中存在错误”。我已在上面粘贴了当前错误。如果有人能帮忙,我将不胜感激。非常感谢。
<dependency>
     <groupId>org.testng</groupId>
     <artifactId>testng</artifactId>
     <version>6.8.8</version>
 </dependency>
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
    </plugins>
</build>