使用 Junit 在 Eclipse 中运行时测试用例通过,但使用 mvn install 失败

问题描述

当我用 Junit 运行测试用例时,它通过了但 mvn install 失败了。

assertEquals(2,flight.getDelayCodes().getLocal().size());

[错误] 失败: [错误] FlightEventHandlerTest.testDelayCodesUpdateFields:302 预期: 但是:

我尝试添加junitdependecny,还是一样的错误 用surefire插件试过还是一样的错误

<plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <forkMode>always</forkMode>
                    <forkCount>4</forkCount>
                    <argLine>${argLine}</argLine>
                    <redirectTestOutputToFile>true</redirectTestOutputToFile>
                    <includes>
                        <include>**/*Test.java</include>
                    </includes>
                    <runorder>Failedfirst</runorder>
                </configuration>
            </plugin>

解决方法

经过几个小时的调试,构建依赖项目再次成功。对我有用。