方法 is(int) 未定义
The method is(int) is undefined
我使用以下方法导入:
import static org.junit.Assert.*;
但是在下面一行:
assertThat(0, is(1));
我得到 The method is(int) is undefined for the type AppTest
.
此方法的名称在英语中很常见,我找不到在哪里导入它。
所以我的问题是,我可以在哪里导入 is
(和 not
)。
你需要
import static org.hamcrest.Matchers.is;
is()
等众多得力助手都是hamcrest Matchers。当然,您需要以某种方式定义相应的依赖项。它可能会有点棘手,因为 hamcrest 有一些核心匹配器,还有匹配器 class 和 "all" 匹配器。但是一旦您确定了哪一个最适合您,您就准备好了,一切都很好。
org.assertj.core.api.Assertions
广泛提供测试用例....
import static org.assertj.core.api.Assertions.*;
assertThat(actual).isEqualTo(expected);
assertThat(actual).isNotEqualTo(expected);
我使用以下方法导入:
import static org.junit.Assert.*;
但是在下面一行:
assertThat(0, is(1));
我得到 The method is(int) is undefined for the type AppTest
.
此方法的名称在英语中很常见,我找不到在哪里导入它。
所以我的问题是,我可以在哪里导入 is
(和 not
)。
你需要
import static org.hamcrest.Matchers.is;
is()
等众多得力助手都是hamcrest Matchers。当然,您需要以某种方式定义相应的依赖项。它可能会有点棘手,因为 hamcrest 有一些核心匹配器,还有匹配器 class 和 "all" 匹配器。但是一旦您确定了哪一个最适合您,您就准备好了,一切都很好。
org.assertj.core.api.Assertions
广泛提供测试用例....
import static org.assertj.core.api.Assertions.*;
assertThat(actual).isEqualTo(expected);
assertThat(actual).isNotEqualTo(expected);