【问题标题】:maven testng.xml test build succesfully but it doesn't run using cmd or jenkinsmaven testng.xml 测试构建成功,但它不使用 cmd 或 jenkins 运行
【发布时间】:2017-07-25 08:27:30
【问题描述】:

我使用以下命令运行我的testng 套件。但它不会打开任何网络浏览器。它只是给出了这个“构建成功”的信息。所以我想知道如何正确运行测试套件。

命令:

mvn clean test -Dsurefire.suiteXmlFiles=mytestng.xml

截图:

TestNg.xml 文件

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >

<suite name="Test121 v1.1">

    <test name="Purchase Order Form">

        <parameter name="venRefNo" value="VnRef0001"/>
        <parameter name="venBillingAddress" value="No420.Vendor Road, Vendor City"/>
        <classes>
            <class name="Procurement._01_PurchaseOrder.TestCases.TestCase_13_Procurement_PurchaseOrder" />
        </classes>
    </test>

    <test name="Inbound Shipment Form">
        <classes>
            <class name="Procurement._01_PurchaseOrder.TestCases.TestCase_13_Procurement_InboundShipment" />
        </classes>
    </test>

    <test name="Purchase Invoice">
        <classes>
            <class name="Procurement._01_PurchaseOrder.TestCases.TestCase_13_Procurement_PurchaseInvoice" />
        </classes>
    </test>

</suite>

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>

    <groupId>test11</groupId>
    <artifactId>test11</artifactId>
    <packaging>pom</packaging>
    <version>1.0-SNAPSHOT</version>

    <dependencies>

        <dependency>
            <artifactId>test11</artifactId>
            <groupId>test11</groupId>
            <version>2.0.5-SNAPSHOT</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>3.4.0</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.testng/testng -->
        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <version>6.11</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>commons-configuration</groupId>
            <artifactId>commons-configuration</artifactId>
            <version>1.6</version>
        </dependency>

        <dependency>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.6.1</version>
        </dependency>

        <dependency>
            <groupId>org.apache.maven.surefire</groupId>
            <artifactId>surefire</artifactId>
            <version>2.20</version>
            <type>pom</type>
        </dependency>

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.20</version>
                <configuration>
                    <suiteXmlFiles>
                        <suiteXmlFile>TestNgSuite.xml</suiteXmlFile>
                    </suiteXmlFiles>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <!-- https://mvnrepository.com/artifact/org.jenkins-ci.main/jenkins-core -->

</project>

【问题讨论】:

  • 你能粘贴你的 testng.xml 吗?
  • 当然,上传错误。当使用 pom.Xml 文件从 jenkins 运行项目时也会发生同样的事情。两个都上传了。

标签: xml maven jenkins testng maven-surefire-plugin


【解决方案1】:

在命令行中,只有清理进程成功。您是否注意到目标文件夹中生成了任何文件???

【讨论】:

  • 是的,已经生成了一些带有 .class 扩展名的文件。但我丢失了目标文件夹中的可靠文件和文件夹。
  • pom.xml 可能有问题,你的 pom 中的代码没有完全执行。所以目标文件夹在清理过程中被清除,但在它之后没有创建。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-03-09
  • 2015-11-15
  • 2015-03-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-09-21
相关资源
最近更新 更多