首页 > 代码库 > Usage and Idioms——Matchers and assertthat

Usage and Idioms——Matchers and assertthat

assertThat

一种插入机制,语法如下:

assertThat([value], [matcher statement]);

例如:

assertThat(x, is(3));

assertThat(x, is(not(4)));

assertThat(responseString, either(containsString("color")).or(containsString("colour")));

assertThat(myList, hasItem("3"));

 

Usage and Idioms——Matchers and assertthat