2つのTestNGリスナーがログ情報をログファイルに報告し、デバッグ情報を取得しています。これらはIConfigurationListener2
とITestListener
です。テストは複数のスレッドで実行されます。TestNG:IConfigurationListener2.beforeConfiguration ITestResultとITestListener.onTestStartをリンクする方法
私の問題は、私は@Test
ITestResult.getMethodName()
を取得するためにITestListener.onTestStart()
ITestResult
にIConfigurationListener2.onConfigurationFailure()
方法でITestResultをリンクする必要があるということです。これは可能ですか?
TestListener
コードは次のとおりです。
public class TestListener implements ITestListener{
@Override
public void onTestStart(ITestResult result) {
System.out.println("Starting test method:" + result.getMethod().getMethodName());
}
}
IConfigurationListener2
は次のとおりです。
public class ConfigurationListener implements IConfigurationListener2 {
@Override
public void onConfigurationFailure(ITestResult result) {
System.out.println("Failed to run " + result.getMethod().getMethodName()
+ " for the test method:" + <code needed>);
}
TestNG
クラスは次のとおりです。
public class Script1 {
private int i =0;
@BeforeMethod
public void before(){
System.out.println("Starting before");
i++;
if (i==1){
throw new RuntimeException("forcing an exception");
}
}
@Test(testName="script1")
public void script1_run(){
System.out.println("Running script");
}
@Test(testName="script2")
public void script2_run(){
System.out.println("Running script");
}
}
それでは、どのように私はどの@Test
方法@beforeMethod
FAを見つけるのですか〜のために育てられた。 、script2_run
感謝を:
は、テストメソッドのために前に実行することができませんでした前に開始スクリプト
を実行script1_run
:
は、試験方法を開始
前に開始:私はこのようなログに何かをしたいと思います
後にスキップされることになっていますか? –
私は新しいアプリケーションをテストし、フレームワークを構築しています。注意書きが記録されている瞬間、私は構成メソッドが失敗したためにテストがスキップされていることがわかります。なぜ、ログ情報を追加する必要があるのですか。 –