gpt4 book ai didi

java - Spring Boot 通过了本应失败的测试用例

转载 作者:行者123 更新时间:2023-11-29 08:32:17 26 4
gpt4 key购买 nike

我在我的 Spring Boot 应用程序中添加了一个测试用例。但是,当我 ./gradlew build 时,所有的测试用例都通过了。有什么原因吗?

@Test
public void testIntentionalError() throws Exception {
boolean thrown = true;
assertThat(!thrown);
}

最佳答案

这是因为你的测试没有测试任何东西。

试试这个:

@Test
public void testIntentionalError() throws Exception {
boolean thrown = true;
assertTrue(!thrown);
}

关于java - Spring Boot 通过了本应失败的测试用例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46914663/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com