【问题标题】:mvn test fails but running the test from IntelliJ IDEA passmvn 测试失败,但从 IntelliJ IDEA 运行测试通过
【发布时间】:2020-03-15 00:45:42
【问题描述】:

我有一个我在下面运行的测试

@RunWith(SpringRunner.class)
@SpringBootTest

@Test
    public void testFind() throws IOException {


Review<Hostel> hostelByComplaintId =
                hostelService.findByComplaintId(complaintId).orElse(null);

        assertThat(hostelByComplaintId).isNotNull();
}

当我从命令行mvn test 运行测试时,我得到了这个错误

Failed tests:
Expecting actual not to be null

但是当我从 IntelliJ IDEA 运行它时,测试并没有失败

【问题讨论】:

  • 如何重现您的问题?请提供minimal, reproducible example
  • 信息不足。盲目猜测:你在终端和 intellij 中使用相同的 maven 版本吗?

标签: java spring spring-boot intellij-idea junit


【解决方案1】:

如果你的项目中有任何测试用例发现它会运行,你可以编写完整的命令

mvn clean install

如果你想禁用运行测试用例

mvn clean install -Dmaven.test.skip=true

【讨论】:

    猜你喜欢
    • 2019-07-31
    • 1970-01-01
    • 2020-06-02
    • 2023-03-26
    • 2020-01-12
    • 1970-01-01
    • 2013-11-08
    • 1970-01-01
    • 2017-10-12
    相关资源
    最近更新 更多