0

我的测试已编译并“运行”,但未执行我的测试方法。Maven 打印:

 T E S T S
-------------------------------------------------------
Running spring.test.Aufgabe0.TestMinimalTestCase
Configuring TestNG with: org.apache.maven.surefire.testng.conf.TestNG652Configurator@4b
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.408 sec

Results :

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

我的测试班真的很小,应该失败:

package spring.test.Aufgabe0;
import org.junit.Test;
import static org.junit.Assert.*;
public class TestMinimalTestCase {
    @Test
    public void testMinimalTest() {
        int i = 3;
        assertTrue(i == 2);
    }
}

如您所见,我导入了 JUnit 并配置了测试路径:

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>${junit.version}</version>
            <scope>test</scope>
        </dependency>
...
    <build>
        <sourceDirectory>src/java</sourceDirectory>
        <testSourceDirectory>src/test</testSourceDirectory>

测试套件在 Eclipse 中运行,但我不知道为什么它不能与 maven 一起使用。

解决方案:

导入 testng 测试。这应该没什么区别:“测试源目录中的测试可以是以下任意组合:TestNG JUnit(3.8 或 4.x)...” Surefire 文档

如何在我的范围/依赖列表中使用 testng 运行 junit 测试?

4

1 回答 1

1
Configuring TestNG with: org.apache.maven.surefire.testng.conf.TestNG652Configurator@4b

看着这个,我想你在 Maven 构建时使用了 TestNG,但是你导入了org.junit.Test.

@Test从 TestNG使用。

于 2013-10-25T17:11:34.473 回答