AssertContains on strings in jUnit

前端 未结 10 1653
清酒与你
清酒与你 2020-12-22 21:09

Is there a nicer way to write in jUnit

String x = \"foo bar\";
Assert.assertTrue(x.contains(\"foo\"));
10条回答
  •  庸人自扰
    2020-12-22 22:13

    Use the new assertThat syntax together with Hamcrest.

    It is available starting with JUnit 4.4.

提交回复
热议问题