【发布时间】:2021-12-23 15:25:15
【问题描述】:
我使用了这个非常简单的代码,并尝试在@AfterSuite 注释下发送可通过电子邮件发送的报告,但问题在于它发送的是旧的(以前的)报告。不是最新的。注意我也试过email方式下的thread.sleep。
package testOWC;
import org.testng.annotations.AfterClass;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.AfterSuite;
import org.testng.annotations.AfterTest;
import org.testng.annotations.Test;
import java.io.IOException;
import javax.mail.MessagingException;
import java.awt.AWTException;
public class All_TestCases {
@SuppressWarnings({ })
@Test (priority =1)
public void RequiredFieldsOnly() throws InterruptedException, IOException, AWTException {
RequiredFieldsOnly.testCase();
}
@Test (priority =2)
public void Yourself() throws InterruptedException, IOException, AWTException {
Yourself.testCase();
}
@Test (priority =3)
public void Yourself_Representative() throws InterruptedException, IOException, AWTException {
Yourself_Representative.testCase();
}
@Test (priority =4)
public void Representative_YourselfNotConf() throws InterruptedException, IOException, AWTException {
Representative_YourselfNotConf.testCase();
}
@Test (priority =5)
public void Representative_YourselfConf() throws InterruptedException, IOException, AWTException {
Representative_YourselfConf.testCase();
}
@AfterSuite
public void email() throws MessagingException, InterruptedException {
Email_Invoke.main(null);
}
}
【问题讨论】:
-
请分享发送邮件的代码
Email_Invoke.main(null) -
感谢@NandanA 的回复。代码没问题。问题是我需要在测试用例执行后运行它。这就是问题所在。
-
您是否正在刷新范围报告?
-
ExtentReports extent = new ExtentReports(ExtentReportsLocationFileName, true);和extent.flush();在发送报告之前执行此操作。