0

在使用以下命令从 Maven 运行我的测试用例时

c:\> mvn test

我得到以下结果:

 D:\arpit_maven\mavenProject\build_demo>mvn test
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building build_demo 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ build_demo
 ---
[debug] execute contextualize
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory D:\arpit_maven\mavenProject\build_dem
o\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ build_demo --
-
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.5:testResources (default-testResources) @ bu
ild_demo ---
[debug] execute contextualize
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory D:\arpit_maven\mavenProject\build_dem
o\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ build
_demo ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.10:test (default-test) @ build_demo ---
[INFO] Surefire report directory: D:\arpit_maven\mavenProject\build_demo\target\
surefire-reports

-------------------------------------------------------
 T E S T S
-------------------------------------------------------

Results :

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

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.031s
[INFO] Finished at: Thu Mar 21 10:29:17 IST 2013
[INFO] Final Memory: 5M/15M
[INFO] ------------------------------------------------------------------------
D:\arpit_maven\mavenProject\build_demo>

我的 POM.xml 如下。如果 pom.xml 中缺少任何内容,请告诉我。我的测试用例在 src\test\java\ 文件夹中。

<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>demo1</groupId>
<artifactId>build_demo</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>build_demo</name>
<url>http://maven.apache.org</url>
<properties>
 <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>

<dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>2.33.0</version>

    </dependency>

 <dependency>
  <groupId>junit</groupId>
  <artifactId>junit</artifactId>
  <version>3.8.1</version>
  <scope>test</scope>
 </dependency>
 <dependency>
<groupId>org.testng</groupId>
 <artifactId>testng</artifactId>
<version>6.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi</artifactId>
        <version>3.8</version>
    </dependency> 
</dependencies>
<build>
    <resources>
        <resource>
            <directory>src/test/resources</directory>
            <filtering>true</filtering>
        </resource>
    </resources>
     <plugins>
     <plugin>
     <groupId>org.apache.mavan.plugins</groupId>
     <artifactId>mavan-compiler-plugin</artifactId>
     <version>2.3.2</version>
     <configuration>
     <source>1.6</source>
     <target>1.6</target>
     </configuration>
     </plugin>
     </plugins>
     </build> 
     <profiles>
    <profile>
        <id>selenium-tests</id>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>2.4.3</version>
                    <configuration>
                        <includes>
                            <include>Opencart.java</include>
                        </includes>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    </profile>
 </profiles>
</project>
4

1 回答 1

2

将您的类重命名为 OpencartTest.java 或更改 surefire 中的过滤器属性,以便它选择您的 Opencart.java 类。您还可以创建显式包含 Opencart.java 的套件 xml 文件。

就个人而言,我只想更改您的班级名称!

于 2013-08-21T10:38:47.737 回答