简体   繁体   English

Maven 不运行测试

[英]Maven don't run tests

I have cucumber framework and the following pom我有黄瓜框架和以下 pom

    <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-spring</artifactId>
        <version>${cucumber.version}</version>
    </dependency>
    <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-junit</artifactId>
        <version>${cucumber.version}</version>
    </dependency>
    <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter</artifactId>
        <version>RELEASE</version>
        <scope>test</scope>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>3.0.0-M5</version>
            <configuration>
                <includes>
                    <include>CucumberE2ETest.java</include>
                </includes>
            </configuration>
        </plugin>
    </plugins>
</build>

After I run my tests, I get this在我运行测试后,我得到了这个

[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] 
[INFO] Results:
[INFO] 
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0

As you can see the Tests run are 0. The tests run fine from IntelliJ but maven does not run the tests.如您所见,测试运行为 0。测试从 IntelliJ 运行良好,但 maven 不运行测试。 My apologies for the large amount of copy-pasted content, but I want to provide as much information as possible because I'm not sure what to try next.对于大量复制粘贴的内容,我深表歉意,但我想提供尽可能多的信息,因为我不确定接下来要尝试什么。

You're using cucumber-junit which integrates with JUnit 4. However because you're using JUnit 5, Surefire will not run JUnit 4 tests.您正在使用与 JUnit 4 集成cucumber-junit但是,由于您使用的是 JUnit 5,Surefire 将不会运行 JUnit 4 测试。 You need to add the JUnit Vintage engine or Cucumber's JUnit 5 integration.您需要添加 JUnit Vintage 引擎或 Cucumber 的 JUnit 5 集成。

See for a working example:有关工作示例,请参见:

https://github.com/cucumber/cucumber-java-skeleton https://github.com/cucumber/cucumber-java-skeleton

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM