Hamcrest:
JUnit4.4引入了Hamcrest框架,Hamcest提供了一套匹配符Matcher,这些匹配符更接近自然语言,可读性高,更加灵活
1、equalTo: assertThat(testedValue, equalTo(expectedValue));
匹配符断言被测的testedValue等于expectedValue, equalTo可以断言数值之间,字符串之间和对象之间是否相等,相当于Object的equals方法
2、equalToIgnoringCase:
assertThat(testedString, equalToIgnoringCase(expectedString));
匹配符断言被测的字符串testedString在忽略大小写的情况下等于expectedString
3、 equalToIgnoringWhiteSpace:
assertThat(testedString, equalToIgnoringWhiteSpace(expectedString);
匹配符断言被测的字符串testedString在忽略头尾的任意个空格的情况下等于expectedString,注意:字符串中的空格不能被忽略
4、containsString :assertThat(testedString, containsString(subString) );
匹配符断言被测的字符串testedString包含子字符串subString**/
5、endsWith:assertThat(testedString, endsWith(suffix));
匹配符断言被测的字符串testedString以子字符串suffix结尾
6、startsWith:assertThat(testedString, startsWith(prefix)); <