Commit e53c6bcf by Li Yongyu

修改邮件和用例

parent 2e0a899a
......@@ -6,7 +6,7 @@
<classes>
<class name="com.puhui.test.RenMai_APITest">
<methods>
<include name="f" invocation-numbers="0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 "/>
<include name="f" invocation-numbers="0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 "/>
</methods>
</class>
</classes>
......
......@@ -12,6 +12,8 @@ import javax.mail.internet.MimeMultipart;
import org.testng.annotations.Test;
import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Properties;
......@@ -126,7 +128,7 @@ public class Mail {
// 4. Subject: 邮件主题
Date date=new Date();
String time=new SimpleDateFormat("yyyyMMdd").format(date);
message.setSubject("nwn接口自动化测试报告-"+time, "UTF-8");
message.setSubject("小雨直播自动化测试报告-"+time, "UTF-8");
/*
* 下面是邮件内容的创建:
......@@ -184,8 +186,17 @@ public class Mail {
MimeBodyPart attachment2 = new MimeBodyPart();
if(ZipUtils.ZipTestResult()){
DataHandler dh2 = new DataHandler(new FileDataSource("F:\\gitCangKu\\Api_auto_test\\test-output\\html\\测试报告详细资料.zip"));
File directory = new File(".");
String mailpath="";
try {
mailpath = directory.getCanonicalPath() +File.separator+"test-output"+File.separator+"html\\";
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
if(ZipUtils.ZipTestResult(mailpath)){
DataHandler dh2 = new DataHandler(new FileDataSource(mailpath+"测试报告详细资料.zip"));
attachment2.setDataHandler(dh2);
attachment2.setFileName("测试报告详细资料.zip");
// // 9. 创建附件"节点"
......@@ -239,6 +250,7 @@ public class Mail {
return message;
}
public static InternetAddress[] parseAddress(String personnel){
String addr="";
if("all".equals(personnel)){
......
......@@ -271,37 +271,39 @@ public class ZipUtils {
/** 测试压缩方法2 */
List<File> fileList = new ArrayList<>();
fileList.add(new File("F:\\gitCangKu\\Api_auto_test\\test-output\\html\\index.html"));
fileList.add(new File("F:\\gitCangKu\\Api_auto_test\\test-output\\html\\overview.html"));
fileList.add(new File("F:\\gitCangKu\\Api_auto_test\\test-output\\html\\reportng.css"));
fileList.add(new File("F:\\gitCangKu\\Api_auto_test\\test-output\\html\\reportng.js"));
fileList.add(new File("F:\\gitCangKu\\Api_auto_test\\test-output\\html\\suite1_test1_results.html"));
fileList.add(new File("F:\\gitCangKu\\Api_auto_test\\test-output\\html\\suites.html"));
// List<File> fileList = new ArrayList<>();
//
// fileList.add(new File(mailpath+"index.html"));
// fileList.add(new File(mailpath+"overview.html"));
// fileList.add(new File(mailpath+"reportng.css"));
// fileList.add(new File(mailpath+"reportng.js"));
// fileList.add(new File(mailpath+"suite1_test1_results.html"));
// fileList.add(new File(mailpath+"suites.html"));
//
//
// FileOutputStream fos2 = new FileOutputStream(new File(mailpath+"mytest02.zip"));
//
// ZipUtils.toZip(fileList, fos2);
FileOutputStream fos2 = new FileOutputStream(new File("F:\\gitCangKu\\Api_auto_test\\test-output\\html\\mytest02.zip"));
}
ZipUtils.toZip(fileList, fos2);
public static boolean ZipTestResult(String mailpath){
}
public static boolean ZipTestResult(){
List<File> fileList = new ArrayList<>();
fileList.add(new File("F:\\gitCangKu\\Api_auto_test\\test-output\\html\\index.html"));
fileList.add(new File("F:\\gitCangKu\\Api_auto_test\\test-output\\html\\overview.html"));
fileList.add(new File("F:\\gitCangKu\\Api_auto_test\\test-output\\html\\reportng.css"));
fileList.add(new File("F:\\gitCangKu\\Api_auto_test\\test-output\\html\\reportng.js"));
fileList.add(new File("F:\\gitCangKu\\Api_auto_test\\test-output\\html\\suite1_test1_results.html"));
fileList.add(new File("F:\\gitCangKu\\Api_auto_test\\test-output\\html\\suites.html"));
fileList.add(new File(mailpath+"index.html"));
fileList.add(new File(mailpath+"overview.html"));
fileList.add(new File(mailpath+"reportng.css"));
fileList.add(new File(mailpath+"reportng.js"));
fileList.add(new File(mailpath+"suite1_test1_results.html"));
fileList.add(new File(mailpath+"suites.html"));
FileOutputStream fos2=null;
try {
fos2 = new FileOutputStream(new File("F:\\gitCangKu\\Api_auto_test\\test-output\\html\\测试报告详细资料.zip"));
fos2 = new FileOutputStream(new File(mailpath+"测试报告详细资料.zip"));
} catch (FileNotFoundException e) {
e.printStackTrace();
return false;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment