expectedExceptionsMessageRegExpがdetailMessageフィールドに一致させようとしています。原因テキストを一致させることはできますか?つまり、Exception.getCause()によって返されるテキスト? detailMessageフィールドが非常に汎用的なメッセージを提供し、期待されるメッセージがそのテキストと一致する場合、テストケースの目的を上回るためです。TestNG expectedExceptionsMessageRegExpを使用して原因テキストを照合することはできますか?
@Test(expectedExceptions = TestExecutionException.class, expectedExceptionsMessageRegExp = ".* HTTP 422.*")
public void test() throws Exception {
..
//some code that produces TestExecutionException with the cause HTTP 422
..
}
TestNGのエラーがある:
The exception was thrown with the wrong message: expected ".* HTTP 422.*" but got "Failed executing MessageExecutionTask"
at org.testng.internal.Invoker.handleInvocationResults(Invoker.java:1481)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:754)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
... 16 more