猿问

方法 is(int) 未定义

我使用以下内容导入:

import static org.junit.Assert.*;

但在以下行:

assertThat(0, is(1));

我明白了The method is(int) is undefined for the type AppTest

这种方法的名称在英语中很常见,我找不到在哪里导入它。

所以我的问题是,我可以在哪里导入is(和not)。


慕哥9229398
浏览 184回答 2
2回答

UYOU

你需要import static org.hamcrest.Matchers.is;is()其他很多大帮手都是hamcrest Matchers。当然,您需要以某种方式定义相应的依赖项。它可能会有点棘手,因为 hamcrest 有一些核心匹配器,并且匹配器类具有“所有”匹配器。但是一旦你确定哪一个最适合你,你就准备好了,一切都很好。

智慧大石

org.assertj.core.api.Assertions广泛提供测试用例....import static org.assertj.core.api.Assertions.*;assertThat(actual).isEqualTo(expected);assertThat(actual).isNotEqualTo(expected);
随时随地看视频慕课网APP

相关分类

Java
我要回答