Surefire测试报告不起作用

时间:2014-07-11 08:23:23

标签: java maven selenium surefire

我是maven的新手,我在制作它时遇到了一些麻烦。

我使用IntellijIDEA在网站上执行一些junit测试(使用selenium webdriver)。 测试执行正确,但我无法确定生成报告。

我想我可能会错过目标或生命周期,但我无法真正理解它们的工作方式和应该放在哪里。 这是我的POM:

<?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">

<groupId>com.lazerycode.selenium</groupId>
<artifactId>maven-template</artifactId>
<version>1.0-SNAPSHOT</version>
<modelVersion>4.0.0</modelVersion>

<name>Selenium Maven Template</name>
<description>A Maven Template For Selenium</description>
<url>http://www.lazerycode.com</url>

<licenses>
    <license>
        <name>Apache 2</name>
        <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
        <distribution>repo</distribution>
        <comments>A business-friendly OSS license</comments>
    </license>
</licenses>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <standalone.binary.root.folder>${project.basedir}/selenium_standalone_binaries</standalone.binary.root.folder>
    <browser>firefox</browser>
    <threads>1</threads>
</properties>

<dependencies>
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-server</artifactId>
        <version>2.41.0</version>
        <scope>test</scope>
        <exclusions>
            <exclusion>
                <groupId>com.opera</groupId>
                <artifactId>operadriver</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>com.opera</groupId>
        <artifactId>operadriver</artifactId>
        <version>1.5</version>
        <scope>test</scope>
        <exclusions>
            <exclusion>
                <groupId>org.seleniumhq.selenium</groupId>
                <artifactId>selenium-remote-driver</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>com.github.detro.ghostdriver</groupId>
        <artifactId>phantomjsdriver</artifactId>
        <version>1.1.0</version>
        <scope>test</scope>
        <exclusions>
            <exclusion>
                <groupId>org.seleniumhq.selenium</groupId>
                <artifactId>selenium-remote-driver</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.testng</groupId>
        <artifactId>testng</artifactId>
        <version>6.8</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.11</version>
        <scope>test</scope>
    </dependency>
</dependencies>

<build>
    <resources>
        <resource>
            <directory>src/main/resources</directory>
            <filtering>true</filtering>
        </resource>
    </resources>
    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
                <version>2.3.2</version>
            </plugin>
        </plugins>
    </pluginManagement>
</build>

<profiles>
    <profile>
        <id>selenium-tests</id>
        <build>
            <plugins>
                <plugin>
                    <groupId>com.lazerycode.selenium</groupId>
                    <artifactId>driver-binary-downloader-maven-plugin</artifactId>
                    <version>1.0.3</version>
                    <configuration>
                        <rootStandaloneServerDirectory>${standalone.binary.root.folder}</rootStandaloneServerDirectory>
                        <downloadedZipFileDirectory>${project.basedir}/selenium_standalone_zips</downloadedZipFileDirectory>
                        <customRepositoryMap>${project.basedir}/RepositoryMap.xml</customRepositoryMap>
                    </configuration>
                    <executions>
                        <execution>
                            <goals>
                                <goal>selenium</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>2.7.2</version>
                    <dependencies>
                        <!-- Force using the latest JUnit 47 provider -->
                        <dependency>
                            <groupId>org.apache.maven.surefire</groupId>
                            <artifactId>surefire-junit47</artifactId>
                            <version>2.8</version>
                        </dependency>
                    </dependencies>
                    <configuration>
                        <includes>
                            <include>**/*/*/*/*.java</include>
                            <include>**/*/*/*.java</include>
                            <include>**/*/*.java</include>
                            <include>**/*.java</include>
                            <include>*.java</include>

                        </includes>
                        <parallel>methods</parallel>
                        <threadCount>${threads}</threadCount>
                    </configuration>

                </plugin>
            </plugins>
        </build>
    </profile>
</profiles>
<reporting>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-report-plugin</artifactId>
            <version>2.17</version>
        </plugin>
    </plugins>
</reporting>

它是使用硒测试模板生成的。有人知道缺少什么吗?

1 个答案:

答案 0 :(得分:0)

首先,您要根据硒的使用情况进行集成测试,因此您应该使用maven-failsafe-plugin代替。 除此之外,您使用的是maven-surefire-plugin版本的2.7.2,但报告您使用的是maven-surefire-report-plugin 2.17 ...所以您应该使用相同版本的maven-surefire-plugin和maven-surefire-报告的插件。