Maven找不到任何测试

时间:2019-05-30 16:49:01

标签: maven junit5

我用类似的项目复制pom.xml都可以。添加需求依赖项。另外,我将Jupiter添加为作用域“编译”,否则项目将无法编译。我试图找到类似问题的解决方案,但没有发现任何问题。

Env:ubuntu 18,idea 2018.3,openjdk8,maven最新版本。

我尝试更改更多新旧版本的junit,surefire插件和junit-platform-surefire-provider,但是找不到需要的组合。

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <java.version>1.8</java.version>
    <junit.api.version>5.4.0</junit.api.version>
    <junit.jupiter.version>5.4.0</junit.jupiter.version>
    <junit.platform.version>1.3.1</junit.platform.version>
    <aspectj.version>1.9.4</aspectj.version>
    <allure.version>2.12.1</allure.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-engine</artifactId>
        <version>${junit.jupiter.version}</version>
    </dependency>
    <dependency>
        <groupId>io.qameta.allure</groupId>
        <groupId>io.qameta.allure</groupId>
        <artifactId>allure-junit5</artifactId>
        <version>${allure.version}</version>
    </dependency>
    <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-api</artifactId>
        <version>5.4.0</version>
        <scope>compile</scope>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.22.2</version>
            <configuration>
                <testFailureIgnore>false</testFailureIgnore>
                <argLine>
                    -javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar"
                </argLine>
                <systemProperties>
                    <property>
                        <name>junit.jupiter.extensions.autodetection.enabled</name>
                        <value>true</value>
                    </property>
                </systemProperties>
            </configuration>
            <dependencies>
                <dependency>
                    <groupId>org.junit.platform</groupId>
                    <artifactId>junit-platform-surefire-provider</artifactId>
                    <version>1.3.2</version>
                </dependency>
                <dependency>
                <groupId>org.aspectj</groupId>
                <artifactId>aspectjweaver</artifactId>
                <version>${aspectj.version}</version>
                </dependency>
            </dependencies>
        </plugin>
        <plugin>
            <groupId>io.qameta.allure</groupId>
            <artifactId>allure-maven</artifactId>
            <version>LATEST_VERSION</version>
            <configuration>
                <reportVersion>2.4.1</reportVersion>
            </configuration>
        </plugin>
    </plugins>
</build>

1 个答案:

答案 0 :(得分:0)

默认情况下,Maven Surefire插件期望您的测试文件名符合以下条件:

  • lastRow = ws.Range("F" & ws.Rows.Count).End(xlUp).Row For R = lastRow To 2 Step -1 With ws If .Cells(R, 6).value = .Cells(R - 1, 6) And .Cells(R, 19).value > 30 Then .Cells(R, 6).EntireRow.Delete End If End With Next R -包括其所有子目录和所有Java 以“测试”开头的文件名。
  • **/Test*.java-包括所有 其子目录以及所有以“ Test”结尾的Java文件名。
  • **/*Test.java-包括其所有子目录和所有Java 以“测试”结尾的文件名。
  • **/*Tests.java-包括所有 的子目录以及所有以。结尾的Java文件名 “ TestCase”。

如果您测试的文件名不符合上述条件,则有两个选择。首先,修改您的测试文件名,使其符合上述条件。其次,您可以通过配置maven-surefire-plugin

修改包含条件
**/*TestCase.java

有关更多信息,请查看the maven-surefire-plugin documentation

相关问题