1

我的 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>com.demo.DemoTestSteps</groupId>
<artifactId>DemoTestSteps</artifactId>
<version>1.0-SNAPSHOT</version>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.0</version>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.11</version>
            <configuration>
                <includes>
                    <include>**/*.java</include>
                </includes>
                <systemPropertyVariables>
                    <propertyName>concordion.output.dir</propertyName>
                    <buildDirectory>target/concordion</buildDirectory>
                </systemPropertyVariables>
            </configuration>
        </plugin>
    </plugins>
</build>

<dependencies>
    <dependency>
        <groupId>org.concordion</groupId>
        <artifactId>concordion</artifactId>
        <version>1.4.3</version>
        <scope>test</scope>
    </dependency>
</dependencies>

这是我的测试课:

package application;

import org.concordion.integration.junit3.ConcordionTestCase;

public class Application extends ConcordionTestCase {
    public void runTest() {
    } 
}

因此,当我使用 运行测试时mvn clean test,将执行测试。但是,如果我稍微修改一下测试类,使其使用juni4,则运行前面的命令不会执行任何操作。

package application;

import org.concordion.integration.junit4.ConcordionRunner;

@RunWith(ConcordionRunner.class)
public class Application {
    public void runTest() {
    } 
}

-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running TestSuite
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.412 sec

Results :

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

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5 seconds
[INFO] Finished at: Fri Feb 01 16:58:18 EET 2013
[INFO] Final Memory: 26M/62M
[INFO] ------------------------------------------------------------------------

有谁知道如何克服这个问题?

4

1 回答 1

2

我刚刚尝试使用您的 pom.xml 和 java 类,它对我有用。

在 JUnit 4 案例中,我确实需要修复缺少的 RunWith 导入。您可能想检查为什么您没有收到编译错误?

它正在使用的版本:

  • 阿帕奇 Maven 3.0.4 (r1232337; 2012-01-17 21:44:56+1300)
  • Java 版本:1.6.0_30,供应商:Sun Microsystems Inc.
于 2013-02-02T10:03:09.980 回答