Maven测试执行给出错误的测试计数

时间:2014-05-14 12:29:20

标签: java maven testing selenium-webdriver

Maven成功执行测试脚本,但它提供了错误的测试计数

以下是该方案:

现在,我有18个测试用例,其中我在通过maven执行时跳过了17个,然后它给了我以下输出。

Tests run: 32, Failures: 0, Errors: 0, Skipped: 31, Time elapsed: 189.559 sec - in TestSuite

Results :

Tests run: 32, Failures: 0, Errors: 0, Skipped: 31

[INFO] ------------------------------------------------------------------------

[INFO] BUILD SUCCESS

[INFO] ------------------------------------------------------------------------

[INFO] Total time: 3:27.578s

[INFO] Finished at: Wed May 14 17:46:40 IST 2014

[INFO] Final Memory: 13M/38M

[INFO] ------------------------------------------------------------------------

POM文件结构

<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>xxxx</groupId>
<artifactId>xxxx</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>xxxx</name>
<url>http://maven.apache.org</url>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
  <plugin>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.1</version>
    <configuration>
      <source>1.7</source>
      <target>1.7</target>
    </configuration>
  </plugin>
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.17</version>
    <configuration>
    <useFile>false</useFile>
    <suiteXmlFiles>
    <suiteXmlFile>abc.xml</suiteXmlFile>
    </suiteXmlFiles>
    </configuration>
  </plugin>
  </plugins>
  </build>

  <repositories>
    <repository>
    <id>java-net</id>
    <url>http://download.java.net/maven/2</url>
  </repository>
  </repositories>
  <dependencies>

<dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-java</artifactId>
    <version>2.40.0</version>
</dependency>
<dependency>
    <groupId>org.testng</groupId>
    <artifactId>testng</artifactId>
    <version>6.8.7</version>
</dependency>
<dependency>
    <groupId>com.google.inject</groupId>
    <artifactId>guice</artifactId>
    <version>3.0</version>
    <scope>test</scope>
    </dependency>
    <dependency>
    <groupId>org.uncommons</groupId>
    <artifactId>reportng</artifactId>
    <version>1.1.2</version>
    <scope>test</scope>
     <exclusions>
        <exclusion>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
        </exclusion>
    </exclusions>
      </dependency>
       <dependency>
    <groupId>org.apache.poi</groupId>
    <artifactId>poi</artifactId>
    <version>3.7</version>
    </dependency>
    <dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.7</version>
    </dependency>
    <dependency>
    <groupId>xml-apis</groupId>
    <artifactId>xml-apis</artifactId>
    <version>1.4.01</version>
    </dependency>  

    </dependencies>

    </project>

1 个答案:

答案 0 :(得分:0)

你可以检查一些事情: - 1.如果您在eclipse中执行,有时会出现此问题。尝试从命令行执行相同的测试。 2.您是否所有测试都只执行一次,使用-X开关重新运行maven以获得完整的跟踪。