詹金斯没有进行我的Selenium测试('没有测试运行')

时间:2018-01-30 01:49:20

标签: java maven selenium jenkins

我有一个香草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 annotation:checked

我的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>
  • 包装= jar:已检查
  • 提及测试范围:已检查

我的詹金斯工作调用了Maven目标:clean integration-test

我错过了什么?

感谢。

1 个答案:

答案 0 :(得分:1)

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

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

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