每次我在Jenkins中使用通用原型配置maven项目时都会出现“编译错误”

时间:2016-07-12 09:49:57

标签: maven jenkins testng

我正在Jenkins中使用通用原型[selenium:webdriver-testNg-archetype]配置maven项目。 我有项目层次结构,如附带的截图1所示。 当我每次遇到“编译错误”时都会用jenkins配置它[如附图2中的show n]但是当我通过eclipse执行测试时我没有收到此错误。

我有另一个问题:当我使用简单的测试用例配置简单的maven项目时,它在Jenkins上成功运行但是当我配置具有层次结构的项目[如截屏1]时,每次我得到“编译错误”的测试包时都没有存在。

我们在Jenkins中有任何设置可以设置测试包的路径吗? 或者我应该做些什么改变才能解决这个问题?

enter image description here Screenshot 2

这是我的pom.xml

<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>com.-----.dashboard</groupId>
<artifactId>dashboard</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>

<dependencies>
    <dependency>
        <groupId>org.testng</groupId>
        <artifactId>testng</artifactId>
        <version>6.9.10</version>
    </dependency>
    <dependency>
        <groupId>ru.stqa.selenium</groupId>
        <artifactId>webdriver-factory</artifactId>
        <version>2.0</version>
    </dependency>
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>2.53.1</version>
    </dependency>
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-server</artifactId>
        <version>2.53.1</version>
    </dependency>
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>htmlunit-driver</artifactId>
        <version>2.20</version>
    </dependency>
    <dependency>
        <groupId>com.codeborne</groupId>
        <artifactId>phantomjsdriver</artifactId>
        <version>1.3.0</version>
    </dependency>
    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi</artifactId>
        <version>3.14</version>
    </dependency>
    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi-ooxml</artifactId>
        <version>3.14</version>
    </dependency>
    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi-ooxml-schemas</artifactId>
        <version>3.14</version>
    </dependency>
    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi-scratchpad</artifactId>
        <version>3.14</version>
    </dependency>
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-ie-driver</artifactId>
        <version>2.53.1</version>
    </dependency>
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>2.53.1</version>
    </dependency>
</dependencies>
<build>
    <resources>
        <resource>
            <directory>src/main/resources</directory>
            <filtering>true</filtering>
        </resource>
    </resources>
    <testResources>
        <testResource>
            <directory>src/test/resources</directory>
            <filtering>true</filtering>
        </testResource>
    </testResources>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-resources-plugin</artifactId>
            <version>2.7</version>
            <configuration>
                <encoding>UTF-8</encoding>
            </configuration>
        </plugin>
        <plugin>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.19.1</version>
            <configuration>
                <suiteXmlFiles>
                    <suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
                </suiteXmlFiles>
                <systemPropertyVariables>
                    <application.properties>/application.properties</application.properties>
                </systemPropertyVariables>
            </configuration>
        </plugin>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.5.1</version>
            <configuration>
                <source>1.7</source>
                <target>1.7</target>
            </configuration>
        </plugin>
    </plugins>
</build>
<!-- profiles -->
<profiles>
    <!-- browsers -->
    <profile>
        <id>firefox</id>
        <properties>
            <capabilities>/firefox.capabilities</capabilities>
        </properties>
        <activation>
            <activeByDefault>true</activeByDefault>
        </activation>
    </profile>
    <profile>
        <id>chrome</id>
        <properties>
            <capabilities>/chrome.capabilities</capabilities>
        </properties>
    </profile>
    <profile>
        <id>ie</id>
        <properties>
            <capabilities>/ie.capabilities</capabilities>
        </properties>
    </profile>
    <profile>
        <id>safari</id>
        <properties>
            <capabilities>/safari.capabilities</capabilities>
        </properties>
    </profile>
    <profile>
        <id>phantomjs</id>
        <properties>
            <capabilities>/phantomjs.capabilities</capabilities>
        </properties>
    </profile>
    <profile>
        <id>opera</id>
        <properties>
            <capabilities>/opera.capabilities</capabilities>
        </properties>
    </profile>
    <profile>
        <id>htmlunit</id>
        <properties>
            <capabilities>/htmlunit.capabilities</capabilities>
        </properties>
    </profile>
    <!-- environments -->
    <profile>
        <id>localhost</id>
        <properties>
            <site.url>http://localhost/</site.url>
        </properties>
        <activation>
            <activeByDefault>true</activeByDefault>
        </activation>
    </profile>
    <profile>
        <id>devhost</id>
        <properties>
            <site.url>http://devhost/</site.url>
        </properties>
    </profile>
    <profile>
        <id>testhost</id>
        <properties>
            <site.url>http://testhost/</site.url>
        </properties>
    </profile>
    <profile>
        <id>prodhost</id>
        <properties>
            <site.url>http://prodhost.com/</site.url>
        </properties>
    </profile>
    <!-- grid -->
    <profile>
        <id>nogrid</id>
        <properties>
            <grid.url></grid.url>
        </properties>
        <activation>
            <activeByDefault>true</activeByDefault>
        </activation>
    </profile>
    <profile>
        <id>grid</id>
        <properties>
            <grid.url>http://localhost:4444/wd/hub/</grid.url>
        </properties>
    </profile>
</profiles>

1 个答案:

答案 0 :(得分:1)

src/test/java是您放置所有测试的文件夹。你不应该从src/main/java文件夹中引用你的测试类  请修好你的课程。