詹金斯无法选择测试用例

问题描述 投票:0回答:1

我正在使用TestNG的maven项目,项目包含1个testcase enter image description here

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

我手动完成时没有任何错误。

我已经配置了一个jenkins maven项目。我已经正确配置了maven和jdk。我已正确地将路径传递给pom.xml目标:test -e

詹金斯不知何故无法运行我的测试用例。它找不到我的测试用例。

Pom.hml:

<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>

请告诉我我错过了什么,为什么jenkins无法选择我的测试用例,尽管手动工作正常。我在我的本地系统上安装了jenkins。 jenkin项目的图片:qazxsw poi

Jenkins控制台输出:

enter image description here
jenkins maven-2 testng
1个回答
0
投票

一眼就看出来了。想知道,是testng.xml的位置对吗?我也会尝试测试testng依赖的范围,比如

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
© www.soinside.com 2019 - 2024. All rights reserved.