Pregunta

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>/...)"

¿Fue útil?

Solución

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);
}
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top