想要一个JUnitMatchers AssertThat来测试字符串包含3个或更多子字符串(当前使用assertThat ...和...和....) [英] Want a JUnitMatchers AssertThat to test string contains 3 or more sub strings (currently using assertThat ... both ... and ....)
本文介绍了想要一个JUnitMatchers AssertThat来测试字符串包含3个或更多子字符串(当前使用assertThat ...和...和....)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
import static org.junit.matchers.JUnitMatchers.both;
import static org.junit.matchers.JUnitMatchers.containsString;
现在我检查它是否包含foo和bar,如下所示...
Now I check it contains foo and bar as below ...
Assert.assertThat(text,
both(containsString("foo")).
and(containsString("bar")));
最干净的测试方法还应检查它是否包含3个或更多字符串,例如'foo','bar'和'baz'吗?
What is cleanest way to test also check it contains 3 or more strings e.g. 'foo', 'bar' and 'baz' ?
推荐答案
查看全文