我正在尝试重构这个不使用的旧代码,ExpectedException
以便它使用它:
try {
//...
fail();
} catch (UniformInterfaceException e) {
assertEquals(404, e.getResponse().getStatus());
assertEquals("Could not find facility for aliasScope = DOESNTEXIST", e.getResponse().getEntity(String.class));
}
而且我无法弄清楚如何做到这一点,因为我不知道如何检查e.getResponse().getStatus()
ore.getResponse().getEntity(String.class)
的值ExpectedException
。我确实看到ExpectedException
有一个需要 hamcrest的expectMatcher
方法。也许这就是关键,但我不确定如何使用它。
如果该状态仅存在于具体异常上,我如何断言该异常处于我想要的状态?