Selenium 在testng的电子邮件报告中打印@BeforeMethod和@AfterMethod的报告者日志
我正在testng的aftermethod中运行一些清理代码。一切都很顺利,但日志没有打印在可通过电子邮件发送的报告上。但它打印在控制台上。 有没有办法在emailable report.html中打印before方法和after方法的日志 提供示例代码Selenium 在testng的电子邮件报告中打印@BeforeMethod和@AfterMethod的报告者日志,selenium,selenium-webdriver,junit,webdriver,testng,Selenium,Selenium Webdriver,Junit,Webdriver,Testng,我正在testng的aftermethod中运行一些清理代码。一切都很顺利,但日志没有打印在可通过电子邮件发送的报告上。但它打印在控制台上。 有没有办法在emailable report.html中打印before方法和after方法的日志 提供示例代码 import java.io.IOException; import java.lang.reflect.Method; import org.testng.Reporter; import org.testng.annotations.Af
import java.io.IOException;
import java.lang.reflect.Method;
import org.testng.Reporter;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
public class AutoItTest {
@BeforeMethod(alwaysRun = true)
public void initialize(Method method) {
Reporter.log("Reporter before");
String methodName = method.getName();
int parameterCount = method.getParameterCount();
String className = this.getClass().getCanonicalName();
Reporter.log("methodName: "+methodName);
Reporter.log("parameterCount: "+parameterCount);
Reporter.log("className: "+className);
long threadId = Thread.currentThread().getId();
Reporter.log("threadId before: "+threadId);
Test test = method.getAnnotation(Test.class);
if (test == null) {
return;
}
Reporter.log(test.testName() + " is currently running");
Reporter.log(test.description() + " was its description");
}
@AfterMethod(alwaysRun = true)
public void uninitialize(Method method) {
Reporter.log("Reporter after");
String methodName = method.getName();
int parameterCount = method.getParameterCount();
String className = this.getClass().getCanonicalName();
long threadId = Thread.currentThread().getId();
Reporter.log("threadId after: "+threadId);
Reporter.log("methodName: "+methodName);
Reporter.log("parameterCount: "+parameterCount);
Reporter.log("className: "+className);
}
@Test(groups = "vdi")
public void VDITest() throws IOException, Exception {
Reporter.log("VDITest");
Reporter.log("Reporter VDITest");
long threadId = Thread.currentThread().getId();
Reporter.log("threadId VDITest: "+threadId);
}
@Test(groups = "vdi")
public void VDITest123() throws IOException, Exception {
Reporter.log("VDITest123");
long threadId = Thread.currentThread().getId();
Reporter.log("threadId VDITest123: "+threadId);
}
}
我想以某种方式整合beforemethod和aftermethod日志我已经找到了答案
@AfterMethod
public void reportTest(ITestResult result) {
Reporter.setCurrentTestResult(result);
Reporter.log("Message to be printed");
}
我添加了Reporter.setCurrentTestResult(结果)@BeforeMethod和@AfterMethod中的代码>以及可通过电子邮件发送的报告上打印的连续日志