我无法理解为什么即使消息正确,我的测试用例也会失败。有没有人遇到过这个问题?它可以是正则表达式匹配吗?如果是这样,那么如何解决它?
使用错误消息抛出异常:预期
"'authority' Uri should have at least one segment in the path (i.e. https://<host>/<path>/...)"
但获得了"'authority' Uri should have at least one segment in the path (i.e. https://<host>/<path>/...)"
答案 0 :(得分:3)
是的,它需要一个正则表达式。你需要逃避括号(和点,但在这种情况下它没有什么区别)。以下测试通过:
@Test(expectedExceptions = RuntimeException.class,
expectedExceptionsMessageRegExp = "'authority' Uri should have at least one segment in the path \\(i.e. https://<host>/<path>/...\\)")
public void test() {
String input = "'authority' Uri should have at least one segment in the path (i.e. https://<host>/<path>/...)";
throw new RuntimeException(input);
}