我创建了一个示例maven项目,我有一个带有以下代码的类
package Basics;
import org.testng.annotations.Test;
public class Second {
@Test
public void jenkinstest()
{
System.out.println("Jenkins test sample");
}
}
以下是testng.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suite">
<test thread-count="5" name="Test">
<classes>
<class name="Basics.Second"/>
</classes>
</test> <!-- Test -->
</suite> <!-- Suite -->
我在Jenkins中创建了一个maven项目并在Root pom字段中提供了上面的项目pom.xml路径,然后当我点击“BuildNow”时,Jenkins的工作表示构建成功但是testng.xml中的脚本没有执行
以下是Jenkins的输出
Started by user anonymous
Building in workspace C:\Users\manchukondaanil_k\.jenkins\workspace\JenkinsRun
Parsing POMs
[Guru99] $ "C:\Program Files\Java\jdk1.8.0_73/bin/java" -cp C:\Users\manchukondaanil_k\.jenkins\plugins\maven-plugin\WEB-INF\lib\maven31-agent-1.5.jar;D:\Selenium_Softwares\apache-maven-3.2.5\boot\plexus-classworlds-2.5.2.jar;D:\Selenium_Softwares\apache-maven-3.2.5/conf/logging jenkins.maven3.agent.Maven31Main D:\Selenium_Softwares\apache-maven-3.2.5 C:\Users\manchukondaanil_k\.jenkins\war\WEB-INF\lib\remoting-2.56.jar C:\Users\manchukondaanil_k\.jenkins\plugins\maven-plugin\WEB-INF\lib\maven31-interceptor-1.5.jar C:\Users\manchukondaanil_k\.jenkins\plugins\maven-plugin\WEB-INF\lib\maven3-interceptor-commons-1.5.jar 52811
<===[JENKINS REMOTING CAPACITY]===>channel started
Executing Maven: -B -f D:\SeleniumProjects\Guru99Project\Guru99\pom.xml clean install
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Guru99 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ Guru99 ---
[INFO] Deleting D:\SeleniumProjects\Guru99Project\Guru99\target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ Guru99 ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory D:\SeleniumProjects\Guru99Project\Guru99\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ Guru99 ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 2 source files to D:\SeleniumProjects\Guru99Project\Guru99\target\classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ Guru99 ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory D:\SeleniumProjects\Guru99Project\Guru99\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ Guru99 ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.4.3:test (default-test) @ Guru99 ---
[INFO] No tests to run.
[JENKINS] Recording test results
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ Guru99 ---
[INFO] Building jar: D:\SeleniumProjects\Guru99Project\Guru99\target\Guru99-0.0.1-SNAPSHOT.jar
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ Guru99 ---
[INFO] Installing D:\SeleniumProjects\Guru99Project\Guru99\target\Guru99-0.0.1-SNAPSHOT.jar to C:\Users\manchukondaanil_k\.m2\repository\Guru99\Guru99\0.0.1-SNAPSHOT\Guru99-0.0.1-SNAPSHOT.jar
[INFO] Installing D:\SeleniumProjects\Guru99Project\Guru99\pom.xml to C:\Users\manchukondaanil_k\.m2\repository\Guru99\Guru99\0.0.1-SNAPSHOT\Guru99-0.0.1-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9.957 s
[INFO] Finished at: 2018-03-28T15:54:07+05:30
[INFO] Final Memory: 24M/181M
[INFO] ------------------------------------------------------------------------
Waiting for Jenkins to finish collecting data
[JENKINS] Archiving D:\SeleniumProjects\Guru99Project\Guru99\pom.xml to Guru99/Guru99/0.0.1-SNAPSHOT/Guru99-0.0.1-SNAPSHOT.pom
[JENKINS] Archiving D:\SeleniumProjects\Guru99Project\Guru99\target\Guru99-0.0.1-SNAPSHOT.jar to Guru99/Guru99/0.0.1-SNAPSHOT/Guru99-0.0.1-SNAPSHOT.jar
channel stopped
Finished: SUCCESS
答案 0 :(得分:0)
您需要在pom.xml的surefire部分指定您的testng.xml,这是需要进行trigerred的testng套件。只是制作testng.xml没有帮助。如果您不想使用xml,那么您需要执行@khmarbaise指向的操作 - 命名文件约定。