mvn测试失败,但是通过IntelliJ IDEA通过运行测试 [英] mvn test fails but running the test from IntelliJ IDEA pass

查看:433
本文介绍了mvn测试失败,但是通过IntelliJ IDEA通过运行测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个可以在

@RunWith(SpringRunner.class)
@SpringBootTest

@Test
    public void testFind() throws IOException {


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

        assertThat(hostelByComplaintId).isNotNull();
}

当我从命令行mvn test运行测试时,出现此错误

when I run the test from the command line mvn test I got this error

Failed tests:
Expecting actual not to be null

但是当我从IntelliJ IDEA运行它时,测试不会失败

but when I run it from IntelliJ IDEA, the test does not fail

推荐答案

如果您的项目中有任何测试用例可以运行,您只需编写完整的命令即可

You can just write complete command if there any test cases in your project found it will run

mvn clean install

如果要禁用运行测试用例

if you want to disable run test cases

mvn clean install -Dmaven.test.skip=true

这篇关于mvn测试失败,但是通过IntelliJ IDEA通过运行测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆