2

我使用Gauge 框架进行自动化测试,我想使用Allure生成报告。不幸的是,Allure 没有为此提供适配器。我的项目由几个模块组成,每个模块都有自己的 pom.xml。

主要 pom.xml(片段):

    <modules>
        <module>libs/common</module>
        <module>tests/panda-api</module>
        <module>tests/dbus-api</module>
    </modules>    
    <dependencies>
        <dependency>
            <groupId>com.thoughtworks.gauge</groupId>
            <artifactId>gauge-java</artifactId>
            <version>0.6.0</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
        </dependency>
    </dependencies>    
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.3</version>
                <configuration>
                    <encoding>UTF-8</encoding>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
        </plugins>
    </build>

子模块 (panda-api) pom.xml:

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <allure.version>1.5.0.RC2</allure.version>
    <aspectj.version>1.8.5</aspectj.version>
</properties>
<dependencies>
    <dependency>
        <groupId>ru.yandex.qatools.allure</groupId>
        <artifactId>allure-junit-adaptor</artifactId>
        <version>${allure.version}</version>
    </dependency>
    <dependency>
        <groupId>ru.yandex.qatools.allure</groupId>
        <artifactId>allure-bundle</artifactId>
        <version>${allure.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-site-plugin</artifactId>
        <version>3.0</version>
    </dependency>
    <dependency>
        <groupId>org.aspectj</groupId>
        <artifactId>aspectjweaver</artifactId>
        <version>${aspectj.version}</version>
    </dependency>
</dependencies>
<build>
    <plugins>
        <plugin>
            <groupId>com.thoughtworks.gauge.maven</groupId>
            <artifactId>gauge-maven-plugin</artifactId>
            <version>1.1.0</version>
            <executions>
                <execution>
                    <phase>test</phase>
                    <configuration>
                        <specsDir>specs</specsDir>
                    </configuration>
                    <goals>
                        <goal>execute</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.19</version>
            <configuration>
                <testFailureIgnore>false</testFailureIgnore>
                <argLine>
                    -Xmx1600m -javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar"
                </argLine>
                <properties>
                    <property>
                        <name>listener</name>
                        <value>ru.yandex.qatools.allure.junit.AllureRunListener</value>
                    </property>
                </properties>
            </configuration>
            <dependencies>
                <dependency>
                    <groupId>org.aspectj</groupId>
                    <artifactId>aspectjweaver</artifactId>
                    <version>${aspectj.version}</version>
                </dependency>
            </dependencies>
        </plugin>
        <plugin>
            <groupId>io.qameta.allure</groupId>
            <artifactId>allure-maven</artifactId>
            <version>2.8</version>
            <configuration>
                <inputDirectories>${project.basedir}/reports/xml-report</inputDirectories>
                <resultsDirectory>allure-results</resultsDirectory>
                <reportDirectory>allure-report</reportDirectory>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-maven-plugin</artifactId>
            <version>9.2.10.v20150310</version>
            <configuration>
                <webAppSourceDirectory>${project.build.directory}/site/allure-maven-plugin</webAppSourceDirectory>
                <stopKey>stop</stopKey>
                <stopPort>1234</stopPort>
                <httpConnector>
                    <port>8090</port>
                </httpConnector>
            </configuration>
        </plugin>
    </plugins>
</build>
<reporting>
    <excludeDefaults>true</excludeDefaults>
    <plugins>
        <plugin>
            <groupId>io.qameta.allure</groupId>
            <artifactId>allure-maven</artifactId>
            <version>2.8</version>
            <configuration>
                <resultsDirectory>allure-results</resultsDirectory>
                <reportDirectory>allure-report</reportDirectory>
            </configuration>
        </plugin>
    </plugins>
</reporting>

我从项目的根目录运行以下命令:

$ mvn clean compile test-compile
$ mvn install -f libs/common/pom.xml
$ mvn gauge:execute -f tests/panda-api/pom.xml -Denv=test -DspecsDir=specs

Gauge 以 JUnit XML Schema 格式生成自己的 XML 报告到“reports/xml-report/result.xml”。Allure 为“allure-report”生成一个空报告,因为不会生成 allure-results。如何根据 Gauge xml-result 生成 Allure 报告?

4

1 回答 1

0

Allure 只接受名称与TEST-*.xmlglob 匹配的 JUnit XML 文件(相关问题https://github.com/allure-framework/allure2/issues/542)。只需重命名文件TEST-results.xml即可解决您的问题。

于 2017-08-26T12:48:59.057 回答