从Jenkins执行TestNG.xml(Maven项目)

问题描述 投票:2回答:1
  1. 我的项目没有bin文件夹
  2. 尝试了以下内容:

D:> java -cp“Pathtolibfolder \ lib *; Pathtobinfolder \ bin”org.testng.TestNG testng.xml

有任何想法吗?

java maven unit-testing jenkins testng
1个回答
2
投票

如果您正在使用Maven,那么我只需使用surefire插件并运行测试作为构建的一部分:

<plugins>

    ...

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>RELEASE</version>
        <configuration>
          <suiteXmlFiles>
            <suiteXmlFile>testng.xml</suiteXmlFile>
          </suiteXmlFiles>
        </configuration>
      </plugin>

    ...

</plugins>

只需指定testng.xml的路径,并在可以使用此类配置时利用它。它允许大量的参数化,我已经在我的项目中广泛使用它。

查看本教程,了解它:http://maven.apache.org/surefire/maven-surefire-plugin/examples/testng.html

© www.soinside.com 2019 - 2024. All rights reserved.