所有套件完成后,我想将testng报告发送到电子邮件。我的发送电子邮件代码可以单独正常工作(我可以顺利接收电子邮件),但是如果我在IExecutionListener.onExecutionFinish()中新建了一个执行电子邮件发送任务的线程,则无法接收电子邮件。
这是我的代码段:
public EmailTask implements Runnable{
@Override
public void run(){
//email sending
}
}
public class QExecutionListener implements IExecutionListener {
private long startTime;
@Override
public void onExecutionStart(){
startTime = System.currentTimeMillis();
System.out.println("QT is going to start");
}
@Override
public void onExecutionFinish(){
System.out.println("QT is finished, took around " + DateUtil.getDurationBreakdown(System.currentTimeMillis() - startTime) );
new Thread(new EmailTask()).start(); //---->not work
}
}