倾城报告+ TestNG + Maven故障安全插件集成

时间:2017-09-12 10:20:40

标签: maven allure

我将使用Allure报告来监控Selenium测试结果。我使用TestNG和Maven故障安全插件来运行测试。我发现了很明显的例子如何修改pom.xml,以便在你使用Maven surefire插件但不包含Maven failsafe插件的情况下包含Allure。我假设配置应该非常相似,但它对我不起作用。这就是我在pom.xml中的内容:

<?xml version="1.0" encoding="UTF-8"?>
<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>vital.com</groupId>
    <artifactId>vital_framework</artifactId>
    <version>0.0.1</version>
    <name>Vital framework</name>
    <description>My first own framework</description>
    <dependencies>
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>3.0.1</version>
        </dependency>
        <dependency>
            <groupId>com.mailosaur</groupId>
            <artifactId>mailosaur-java</artifactId>
            <version>3.0.2</version>
        </dependency>
        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <version>6.8</version>
        </dependency>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.17</version>
        </dependency>
        <dependency>
            <groupId>ru.yandex.qatools.allure</groupId>
            <artifactId>allure-testng-adaptor</artifactId>
            <version>${allure.version}</version>
        </dependency>
        <!-- <dependency> <groupId>com.codeborne</groupId> <artifactId>phantomjsdriver</artifactId> 
            <version>1.2.1</version> </dependency> -->
    </dependencies>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <!-- Dependency versions -->
        <selenium.version>LATEST</selenium.version>
        <!-- Configurable variables -->
        <threads>2</threads>
        <browser>firefox</browser>
        <overwrite.binaries>false</overwrite.binaries>
        <!-- Acceptable values: dev, test, uat, prod -->
        <environment>test</environment>
        <aspectj.version>1.7.4</aspectj.version>
        <allure.version>{latest-allure-version}</allure.version>
    </properties>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>2.19.1</version>
                <configuration>
                    <suiteXmlFiles>
                        <suiteXmlFile>testng.xml</suiteXmlFile>
                    </suiteXmlFiles>
                    <argLine>
                        -javaagent:${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar
                    </argLine>
                    <parallel>methods</parallel>
                    <parallel>true</parallel>
                    <threadCount>${threads}</threadCount>
                    <systemPropertyVariables>
                        <browser>${browser}</browser>
                        <environment>${environment}</environment>
                        <screenshotDirectory>${project.build.directory}/screenshots</screenshotDirectory>
                        <!--Set properties passed in by the driver binary downloader -->
                        <phantomjs.binary.path>${phantomjs.binary.path}</phantomjs.binary.path>
                        <webdriver.chrome.driver>${webdriver.chrome.driver}</webdriver.chrome.driver>
                        <webdriver.ie.driver>${webdriver.ie.driver}</webdriver.ie.driver>
                        <webdriver.opera.driver>${webdriver.opera.driver}</webdriver.opera.driver>
                        <webdriver.gecko.driver>${webdriver.gecko.driver}</webdriver.gecko.driver>
                    </systemPropertyVariables>
                    <includes>
                        <!-- <include>**/*WD.java</include> -->
                        <include>**/*WD.java</include>
                    </includes>
                    <properties>
                        <property>
                            <name>listener</name>
                            <value>ru.yandex.qatools.allure.testng.AllureTestListener</value>
                        </property>
                    </properties>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>org.aspectj</groupId>
                        <artifactId>aspectjweaver</artifactId>
                        <version>${aspectj.version}</version>
                    </dependency>
                </dependencies>
                <executions>
                    <execution>
                        <goals>
                            <goal>integration-test</goal>
                            <goal>verify</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>com.lazerycode.selenium</groupId>
                <artifactId>driver-binary-downloader-maven-plugin</artifactId>
                <version>1.0.11</version>
                <configuration>
                    <rootStandaloneServerDirectory>${project.basedir}/src/test/resources/selenium_standalone_binaries</rootStandaloneServerDirectory>
                    <downloadedZipFileDirectory>${project.basedir}/src/test/resources/selenium_standalone_zips</downloadedZipFileDirectory>
                    <customRepositoryMap>${project.basedir}/src/test/resources/RepositoryMap.xml</customRepositoryMap>
                    <overwriteFilesThatExist>${overwrite.binaries}</overwriteFilesThatExist>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>selenium</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

这是我看到的错误:

[ERROR] Failed to execute goal on project vital_framework: Could not resolve dependencies for project vital.com:vital_framework:jar:0.0.1: Failure to find ru.yandex.qatools.allure:allure-testng-adaptor:jar:{latest-allure-version} in https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced -> [Help 1]

任何建议都表示赞赏。我假设在pom.xml中配置Maven故障安全插件有问题。我按照此设置https://github.com/allure-framework/allure1/wiki/TestNG

1 个答案:

答案 0 :(得分:0)

文档使用以下

<properties>
    <allure.version>{latest-allure-version}</allure.version>
</properties>

这基本上意味着你仍然指的是一些尚未解决的变量。我建议您将{latest-allure-version}替换为实际最新发布的版本号,然后重试。

哦,顺便说一下,您所指的文档和项目是已过时。你应该引用here