문제

I am failing to understand why my test case is failing even when the message is correct. Has anyone run into this issue before? Could it be regex matching? If so, then how to fix it?

The exception was thrown with the wrong message: expected "'authority' Uri should have at least one segment in the path (i.e. https://<host>/<path>/...)" but got "'authority' Uri should have at least one segment in the path (i.e. https://<host>/<path>/...)"

도움이 되었습니까?

해결책

Yes it expects a regex. You need to escape the brackets (and the dots but it makes little difference in this case). The test below passes:

@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);
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top