IInvokedMethodListener を実装する TestNG リスナーがあります。@BeforeMethod では、いくつかのテスト コンテキストを設定する必要があります。例を次に示します。
public class ThucydidesInvokedMethodListener implements IInvokedMethodListener2 {
public void beforeInvocation(final IInvokedMethod method, final ITestResult testResult) {
boolean areBeforeMethods = method.getTestMethod().getTestClass().getBeforeTestMethods().length > 0;
if ((areBeforeMethods && method.getTestMethod().getTestClass().getBeforeTestMethods()[0] == method.getTestMethod()) ||
!areBeforeMethods && method.isTestMethod()) {
final ThucydidesTestContext context = new ThucydidesTestContext(testResult);
testResult.setAttribute(contextKey(), context);
context.before();
}
}
レポートでこのテスト名を使用するには、BeforeMethod の後に実行されるテスト名も必要です。これは TestNG を使用して可能ですか? また、追加で ITestContext を持つ IInvokedMethodListener2 を試しましたが、テスト名も提供していません。