想用pom.xml运行ant项目中的junit测试套件

时间:2010-08-09 15:40:02

标签: maven-2

我有一个带有JUnit测试套件的Ant项目。没有源代码,但测试在类路径中的jar上运行。我的要求是在pom.xml之外的同一个Ant项目中编写build.xml并运行相同的JUnit测试套件。现在运行Maven时,我得到了这个......

[INFO] [surefire:test]
[INFO] Surefire report directory: C:\MIS_SVN\onb-services-test-cases\target\surefire-reports

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
There are no tests to run.

Results :

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

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 14 seconds
[INFO] Finished at: Mon Aug 09 10:17:15 CDT 2010
[INFO] Final Memory: 2M/9M
[INFO] ------------------------------------------------------------------------

我的pom.xml是

    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.3.1</version>
    </dependency>
    <dependency>
        <groupId>com.tibco.ems</groupId>
        <artifactId>tibjms</artifactId>
        <version>4.4.1</version>
    </dependency>
    <dependency>
        <groupId>cglib</groupId>
        <artifactId>cglib-nodep</artifactId>
        <version>2.1_3</version>
    </dependency>
</dependencies>
<build>
    <directory>${basedir}/target</directory>
    <outputDirectory>${basedir}/build/classes</outputDirectory>
    <!--<testOutputDirectory>${basedir}/build/test-classes</testOutputDirectory>-->
    <sourceDirectory>${basedir}/src/java</sourceDirectory>
    <testSourceDirectory>${basedir}/src/java</testSourceDirectory>

    <resources>
        <resource>
            <directory>${basedir}/src/java/com/uprr/app/onb/cdfpostprocessor</directory>
        </resource>
    </resources>

    <testResources>
        <testResource>
            <directory>${basedir}/src/java/com/uprr/app/onb/cdfpostprocessor</directory>
        </testResource>
        <testResource>
            <directory>${basedir}/test/test-data</directory>
        </testResource>
    </testResources>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.0.2</version>
            <configuration>
                <fork>true</fork>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-report-plugin</artifactId>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
                <includes>
                    <include>**/CDFPostProcessorTester.java</include>
                    <include>**/CDFPPTestSuite.java</include>
                    <include>**/LocationSummaryTester.java</include>
                </includes>
                <outputDirectory>${basedir}/test/surefire-reports</outputDirectory>
            </configuration>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>report</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

    </plugins>
</build>
</project>

1 个答案:

答案 0 :(得分:0)

您可以尝试使用目标exec:java的{​​{3}},将其挂钩到maven-exec-plugin中的test阶段,将依赖项(您的测试jar)添加到插件中,最后配置mainClass