【问题标题】:Jenkins doesn't run my Selenium tests ('No tests to run')Jenkins 没有运行我的 Selenium 测试(“没有要运行的测试”)
【发布时间】:2018-07-08 19:46:03
【问题描述】:

我有一个普通的 Selenium 项目,我想用 Jenkins 运行它。我一直在阅读如此多的 SO 帖子,并在我的项目中进行了一些更正,以使我的测试可见。无论如何,当我尝试在 Jenkins 中运行测试时,我最终会收到一条 'No tests to run' 消息。这令人困惑。

让我展示我的东西。

我的一种测试方法:

package tests;

import junitparams.JUnitParamsRunner;
import org.junit.Test;
import org.junit.runner.RunWith;
import junitparams.FileParameters;
import pages.AnyPage;
import utils.AbstractTest;

@RunWith(JUnitParamsRunner.class)
public class DisponibiliteSitesWebTest extends AbstractTest {

    @Test
    @FileParameters("src\\selenium\\resources\\check_websites.csv")
    public void test_AffichageTexte(String url, String texteATrouver) {
        accesURL(url);
        AnyPage page = new AnyPage(this);
        page.assertTextDisplayed(texteATrouver);
    }
}
  • 'test' 包存在:已检查
  • 测试命名约定:选中
  • @Test 注解:勾选

我的 POM:

<project
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
        xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

    <modelVersion>4.0.0</modelVersion>

    <groupId>org.hightest.nc</groupId>
    <artifactId>poc</artifactId>
    <!--<packaging>pom</packaging>-->
    <packaging>jar</packaging>
    <version>1.0</version>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
                <configuration>
                    <skip>${skip.selenium.tests}</skip>
                    <parallel>none</parallel>
                    <threadCount>1</threadCount>
                    <reuseForks>false</reuseForks>
                    <disableXmlReport>true</disableXmlReport>
                </configuration>
                <executions>
                    <execution>
                        <id>runSeleniumTests</id>
                        <phase>integration-test</phase>
                        <goals>
                            <goal>integration-test</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <dependencies>
        <dependency>
            <groupId>org.codehaus.groovy</groupId>
            <artifactId>groovy-all</artifactId>
            <version>2.4.7</version>
        </dependency>
        <dependency>
            <groupId>org.gebish</groupId>
            <artifactId>geb-core</artifactId>
            <version>1.0</version>
        </dependency>
        <dependency>
            <groupId>org.gebish</groupId>
            <artifactId>geb-spock</artifactId>
            <version>1.0</version>
        </dependency>
        <dependency>
            <groupId>org.spockframework</groupId>
            <artifactId>spock-core</artifactId>
            <version>1.0-groovy-2.4</version>
        </dependency>
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-remote-driver</artifactId>
            <version>3.8.0</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-firefox-driver</artifactId>
            <version>3.8.0</version>
        </dependency>
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>3.8.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>4.5.1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.17</version>
        </dependency>
        <dependency>
            <groupId>pl.pragmatists</groupId>
            <artifactId>JUnitParams</artifactId>
            <version>1.1.1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.pdfbox</groupId>
            <artifactId>pdfbox</artifactId>
            <version>2.0.6</version>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-io</artifactId>
            <version>1.3.2</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
</project>
  • 包装 = 罐子:检查
  • 提及的测试范围:已检查

我的 Jenkins 工作调用 Maven 目标:clean integration-test

我错过了什么?

谢谢。

【问题讨论】:

  • 您是否在本地运行clean integration-test?结果如何?
  • 同样的错误。但我找到了答案……在另一个我以前没见过的 SO 帖子中。

标签: java maven selenium jenkins


【解决方案1】:

我终于找到了答案。问题是我的项目目录配置。

它是 src/selenium/java/** 而不是 src/test/java。

我在另一个我从未见过的 SO 问题中找到了答案。 https://stackoverflow.com/a/36172200/7093031

【讨论】:

    猜你喜欢
    • 2022-12-10
    • 2014-02-04
    • 2021-04-18
    • 1970-01-01
    • 2019-09-04
    • 2013-12-09
    • 1970-01-01
    • 1970-01-01
    • 2018-06-01
    相关资源
    最近更新 更多