質問

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