mvn测试失败,但是通过IntelliJ IDEA通过运行测试

时间:2019-11-19 13:19:01

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

我有一个在

下运行的测试
@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运行它时,测试不会失败

1 个答案:

答案 0 :(得分:0)

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

mvn clean install

如果要禁用运行测试用例

mvn clean install -Dmaven.test.skip=true