简体   繁体   English

我无法在 Maven 中使用 mvn test 运行我的测试

[英]I can´t run my tests using mvn test in Maven

I have the following POM:我有以下POM:

<?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.manning.junitbook</groupId>
<artifactId>ch13-continuous</artifactId>
<version>1.0-SNAPSHOT</version>

<name>ch13-continuous</name>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>

    <sonar.coverage.jacoco.xmlReportPaths>target\site\jacoco\jacoco.xml</sonar.coverage.jacoco.xmlReportPaths>
    <sonar.junit.reportPaths>target\surefire-reports</sonar.junit.reportPaths>

</properties>

<build>
    <plugins>
        <plugin>
            <groupId>org.jacoco</groupId>
            <artifactId>jacoco-maven-plugin</artifactId>
            <version>0.8.5</version>
            <executions>
                <execution>
                    <id>report</id>
                    <goals>
                        <goal>report</goal>
                    </goals>
                    <phase>verify</phase>
                </execution>
            </executions>
        </plugin>

        <plugin>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.22.1</version>
        </plugin>
    </plugins>


</build>

<dependencies>
    <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-api</artifactId>
        <version>5.6.0</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-engine</artifactId>
        <version>5.6.0</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.13</version>
        <scope>test</scope>
    </dependency>


</dependencies>

And I have some test called "FlightTests" and "PassengerTests" into my directory /test/java/es.ull/flights and /test/java/es.ull/passenger respectly.我在我的目录 /test/java/es.ull/flights 和 /test/java/es.ull/passenger 中有一些名为“FlightTests”和“PassengerTests”的测试。 However, when I launch mvn test on IntelliJ it ended up showing this:但是,当我在 IntelliJ 上启动 mvn test 时,它最终显示如下:

[INFO] Results:
[INFO] 
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0

Why is this happening??为什么会这样?? I assume that it can´t localice my tests, but I don´t know why.我认为它无法本地化我的测试,但我不知道为什么。

Maybe you can try with new version.也许你可以试试新版本。

   <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>3.0.0-M5</version>
            <configuration>
              <includes>
                <include>*Test.java</include>
              </includes>
            </configuration>
  </plugin>

Also you can use jupiter and try junit5 with jupiter depedencies.您也可以使用 jupiter 并尝试使用 jupiter depedencies 的 junit5。 For example use @Test annotation from jupiter dependency.例如使用来自 jupiter 依赖的 @Test 注解。

You have some test files called "FlightTests" and "PassengerTests" and that is the issue, Could you please change the name as "FlightTest" and "PassengerTest", by removing the s at the end, or it will not recognize the tests.您有一些名为“FlightTests”和“PassengerTests”的测试文件,这就是问题所在,您能否通过删除末尾的 s 将名称更改为“FlightTest”和“PassengerTest”,否则它将无法识别测试。 I have verified it.我已经验证过了。

暂无
暂无

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

相关问题 Maven无法在mvn -test上运行Junit测试 - Maven failing to run Junit Tests on mvn -test 我怎样才能让Maven在“ MVN测试”中运行MySQL插件 - How can I get maven to run mySQL plug at “mvn test” 我的测试正在运行,然后我单击“运行为--&gt; Maven clean”,现在当我单击“运行为--&gt; Maven 测试”时,它不再起作用 - My tests were running and then I clicked “Run as --> Maven clean” and now when I click “Run as --> Maven test” it doesn't work anymore 为什么“mvn verify”没有运行我的集成测试? - Why doesn't “mvn verify” run my integration tests? maven测试不运行测试 - maven test don't run tests 为什么我可以使用 mvn spring-boot:run 启动我的应用程序而 IntelliJ run 不起作用? - Why can I start my application using mvn spring-boot:run while IntelliJ run doen´t work? Maven项目(Cucumber + TestNG + Selenium-Java)测试无法使用mvn clean install在命令行上运行测试 - Maven Project(Cucumber+TestNG+Selenium-Java] Test Can't Run test on command line with mvn clean install 我如何让 mvn cobertura:cobertura 不运行比 mvn test 更多的测试 - how do I make mvn cobertura:cobertura not run more tests than mvn test 当我从 testng.xml 运行我的测试套件时,我在 Allure 报告中看到了步骤。 但是当使用“mvn clean test”时我没有看到任何步骤 - When I run my test suite from testng.xml, I see Steps in the Allure report. But when using "mvn clean test" I don't see any steps 如何在`mvn test`上添加Maven exec任务来执行 - How can I add a Maven exec task to execute on `mvn test`
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM