【发布时间】:2017-01-04 09:17:33
【问题描述】:
我在 Eclipse 中使用 java 创建了几个 Selenium 测试用例。我想使用 Jenkins 运行这些测试。我也在使用 Maven 构建自动化工具。 当我在 Jenkins 中使用立即构建功能时,我在控制台输出中收到构建成功消息,但测试未运行。 我想知道我应该如何从 Jenkins 调用 Main 方法。是否有一些插件需要添加到我的 pom 文件中。
[在此处输入图片描述][2] enter image description here
我正在复制下面的当前 POM 文件:
<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>SecondOne</groupId>
<artifactId>Project2</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.45.0</version>
</dependency>
<dependency>
<groupId>org.jopendocument</groupId>
<artifactId>jOpenDocument</artifactId>
<version>1.3b1</version>
</dependency>
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>itextpdf</artifactId>
<version>5.5.4</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.1</version>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
<version>1.1</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>src.main.java.pack1.FirstClass</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<inherited>true</inherited>
</plugin>
</plugins>
</build>
</project>
请注意,我不使用 TestNG 或任何其他常见的测试框架。 非常感谢您的帮助
【问题讨论】:
-
jenkins 为什么要运行你的程序?
-
您在 Jenkins 中构建 mvn 程序时使用的命令是什么?你想知道什么 - 运行测试用例或找出主类?
-
@RavindraDevadiga - 我使用了 Jenkins 仪表板中的“立即构建”功能。此外,在 Jenkins 项目的“配置”选项卡中,我添加了 POM 文件的路径,并将“目标和选项”字段设置为清理测试。我想运行测试用例。
-
@tkausl - 我正在尝试使用 Jenkins 运行我的 Selenium 测试,以便我可以安排测试运行。
标签: java eclipse maven selenium jenkins