【问题标题】:How to run junit4 based concordion tests with maven?如何使用 maven 运行基于 junit4 的协和测试?
【发布时间】:2013-01-16 22:18:56
【问题描述】:

我的 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] ------------------------------------------------------------------------

有人知道如何解决这个问题吗?

【问题讨论】:

  • 看看this question的答案。他们正在成功运行 Concordion JUnit 4 测试。

标签: maven concordion


【解决方案1】:

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

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

它正在使用的版本:

  • Apache Maven 3.0.4 (r1232337; 2012-01-17 21:44:56+1300)
  • Java 版本:1.6.0_30,供应商:Sun Microsystems Inc.

【讨论】:

    猜你喜欢
    • 2015-03-04
    • 2011-12-09
    • 2015-12-08
    • 2019-11-20
    • 2014-08-08
    • 1970-01-01
    • 2011-01-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多