【问题标题】:Jenkins not able to pick Test cases詹金斯无法选择测试用例
【发布时间】:2016-09-03 22:16:44
【问题描述】:

我正在使用带有 TestNG 的 maven 项目,项目包含 1 个测试用例

当我使用 cmd 手动运行 maven 时,测试套件会正确执行。 mvn 测试 -e

当我手动操作时,我没有收到任何错误。

我已经配置了一个 jenkins maven 项目。 我已经正确配置了 maven & jdk。 我已经正确传递了 pom.xml 的路径 目标:测试-e

Jenkins 不知何故无法运行我的测试用例。 它没有找到我的测试用例。

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>Jenkin_Demo_Project</groupId>
  <artifactId>Jenkin_Demo_Project</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <build>
    <sourceDirectory>src</sourceDirectory>
    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.5.1</version>
        <configuration>
          <source>1.8</source>
          <target>1.8</target>
        </configuration>
      </plugin>
      <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.14</version>
                <configuration>
                <suiteXmlFiles>
               <suiteXmlFile>testng.xml</suiteXmlFile>
          </suiteXmlFiles>
                    <testFailureIgnore>false</testFailureIgnore>
                    <systemProperties>
                        <property>
                            <name>listener</name>
                            <value>ru.yandex.qatools.allure.testng.AllureTestListener</value>
                        </property>
                    </systemProperties>
                </configuration>
                </plugin>
    </plugins>
  </build>
  <dependencies>
     <dependency>
      <groupId>io.appium</groupId>
      <artifactId>java-client</artifactId>
      <version>3.3.0</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>org.seleniumhq.selenium</groupId>
      <artifactId>selenium-java</artifactId>
      <version>2.48.2</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>org.testng</groupId>
        <artifactId>testng</artifactId>
        <version>6.9.10</version>
    </dependency>
  </dependencies>
</project>

TestNG.xml:

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Example test run">
  <test name="StartTest">
    <classes>
      <class name="TestCase.StartApplication"/>
      </classes>
  </test>
</suite>

请告诉我我缺少什么,为什么 jenkin 无法选择我的测试用例,尽管手动它工作正常。 我在本地系统上安装了 jenkins。 詹金项目的形象:

Jenkins 控制台输出:

Started by user neha1
Building in workspace C:\Program Files (x86)\Jenkins\workspace\GitMavenProject
 > C:\Program Files (x86)\Git\cmd\git.exe rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
 > C:\Program Files (x86)\Git\cmd\git.exe config remote.origin.url https://github.com/nehabedi/Repo1.git # timeout=10
Fetching upstream changes from https://github.com/nehabedi/Repo1.git
 > C:\Program Files (x86)\Git\cmd\git.exe --version # timeout=10
Setting http proxy: 172.18.65.22:80
 > C:\Program Files (x86)\Git\cmd\git.exe -c core.askpass=true fetch --tags --progress https://github.com/nehabedi/Repo1.git +refs/heads/*:refs/remotes/origin/*
 > C:\Program Files (x86)\Git\cmd\git.exe rev-parse "refs/remotes/origin/master^{commit}" # timeout=10
 > C:\Program Files (x86)\Git\cmd\git.exe rev-parse "refs/remotes/origin/origin/master^{commit}" # timeout=10
Checking out Revision c63d32391414a2a8368c74fb34733fafc66fc5f6 (refs/remotes/origin/master)
 > C:\Program Files (x86)\Git\cmd\git.exe config core.sparsecheckout # timeout=10
 > C:\Program Files (x86)\Git\cmd\git.exe checkout -f c63d32391414a2a8368c74fb34733fafc66fc5f6
 > C:\Program Files (x86)\Git\cmd\git.exe rev-list c63d32391414a2a8368c74fb34733fafc66fc5f6 # timeout=10
Parsing POMs
[Jenkin_Demo_Project] $ "C:\Program Files\Java\jdk1.8.0_74/bin/java" -cp "C:\Program Files (x86)\Jenkins\plugins\maven-plugin\WEB-INF\lib\maven31-agent-1.5.jar;D:\apache-maven-3.2.5\boot\plexus-classworlds-2.5.2.jar;D:\apache-maven-3.2.5/conf/logging" jenkins.maven3.agent.Maven31Main D:\apache-maven-3.2.5 "C:\Program Files (x86)\Jenkins\war\WEB-INF\lib\remoting-2.53.3.jar" "C:\Program Files (x86)\Jenkins\plugins\maven-plugin\WEB-INF\lib\maven31-interceptor-1.5.jar" "C:\Program Files (x86)\Jenkins\plugins\maven-plugin\WEB-INF\lib\maven3-interceptor-commons-1.5.jar" 52804
<===[JENKINS REMOTING CAPACITY]===>channel started
Executing Maven:  -B -f C:\Program Files (x86)\Jenkins\workspace\GitMavenProject\Jenkin_Demo_Project\pom.xml clean test
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building Jenkin_Demo_Project 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ Jenkin_Demo_Project ---
[INFO] Deleting C:\Program Files (x86)\Jenkins\workspace\GitMavenProject\Jenkin_Demo_Project\target
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ Jenkin_Demo_Project ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\Program Files (x86)\Jenkins\workspace\GitMavenProject\Jenkin_Demo_Project\src\main\resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.5.1:compile (default-compile) @ Jenkin_Demo_Project ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
[INFO] Compiling 1 source file to C:\Program Files (x86)\Jenkins\workspace\GitMavenProject\Jenkin_Demo_Project\target\classes
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ Jenkin_Demo_Project ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\Program Files (x86)\Jenkins\workspace\GitMavenProject\Jenkin_Demo_Project\src\test\resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.5.1:testCompile (default-testCompile) @ Jenkin_Demo_Project ---
[INFO] No sources to compile
[INFO] 
[INFO] --- maven-surefire-plugin:2.14:test (default-test) @ Jenkin_Demo_Project ---
[INFO] No tests to run.
[INFO] Surefire report directory: C:\Program Files (x86)\Jenkins\workspace\GitMavenProject\Jenkin_Demo_Project\target\surefire-reports

-------------------------------------------------------
 T E S T S
-------------------------------------------------------

Results :

Tests run: 0, Failures: 0, Errors: 0, Skipped: 0

【问题讨论】:

  • 请张贴 jenkins 的控制台日志..你在某处签到..代码签出了吗?
  • 您好 Neha,您找到任何解决方案了吗?即使我没有收到任何错误,但没有一个测试用例开始执行。

标签: jenkins maven-2 testng


【解决方案1】:

乍一看,这看起来不错。想知道,testng.xml 的位置对吗?我也会尝试测试 testng 依赖的范围,比如

<dependency>
  <groupId>org.testng</groupId>
  <artifactId>testng</artifactId>
  <version>6.9.10</version>
  <test>
</dependency>

【讨论】:

  • 我可以使用 eclipse(作为 maven 测试运行)也可以使用命令提示符来执行它。它只适用于詹金斯它不起作用。
  • 您在 jenkins 控制台中看到的错误/信息是什么?另外,请在编辑目标和选项后检查 -Dtests=src/test/resources/testng.xml 测试
  • 跳过不存在的资源目录 D:\Dexcom_project\CGM\integration-tests\Jenkin_Demo_Project\src\main\resources。
  • 我没有配置选择“D:\Dexcom_project\CGM\integration-tests\Jenkin_Demo_Project\src\main\resources”路径来访问文件。在 pom.xml 中,我指定了 testng.xml 的正确路径,在 testng.xml 中,我指定了包含测试用例的类的位置。
  • 想知道,在编辑目标和选项后,您是否看到同样的问题?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-08-16
  • 1970-01-01
  • 2022-12-16
  • 1970-01-01
  • 2019-12-11
  • 2023-01-26
  • 1970-01-01
相关资源
最近更新 更多