Commit e53c6bcf by Li Yongyu

修改邮件和用例

parent 2e0a899a
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<classes> <classes>
<class name="com.puhui.test.RenMai_APITest"> <class name="com.puhui.test.RenMai_APITest">
<methods> <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> </methods>
</class> </class>
</classes> </classes>
......
...@@ -12,6 +12,8 @@ import javax.mail.internet.MimeMultipart; ...@@ -12,6 +12,8 @@ import javax.mail.internet.MimeMultipart;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import java.util.Properties; import java.util.Properties;
...@@ -126,7 +128,7 @@ public class Mail { ...@@ -126,7 +128,7 @@ public class Mail {
// 4. Subject: 邮件主题 // 4. Subject: 邮件主题
Date date=new Date(); Date date=new Date();
String time=new SimpleDateFormat("yyyyMMdd").format(date); String time=new SimpleDateFormat("yyyyMMdd").format(date);
message.setSubject("nwn接口自动化测试报告-"+time, "UTF-8"); message.setSubject("小雨直播自动化测试报告-"+time, "UTF-8");
/* /*
* 下面是邮件内容的创建: * 下面是邮件内容的创建:
...@@ -183,9 +185,18 @@ public class Mail { ...@@ -183,9 +185,18 @@ public class Mail {
// text_image.setContent(mm_text_image); // text_image.setContent(mm_text_image);
MimeBodyPart attachment2 = new MimeBodyPart(); MimeBodyPart attachment2 = new MimeBodyPart();
if(ZipUtils.ZipTestResult()){ File directory = new File(".");
DataHandler dh2 = new DataHandler(new FileDataSource("F:\\gitCangKu\\Api_auto_test\\test-output\\html\\测试报告详细资料.zip")); 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.setDataHandler(dh2);
attachment2.setFileName("测试报告详细资料.zip"); attachment2.setFileName("测试报告详细资料.zip");
// // 9. 创建附件"节点" // // 9. 创建附件"节点"
...@@ -239,6 +250,7 @@ public class Mail { ...@@ -239,6 +250,7 @@ public class Mail {
return message; return message;
} }
public static InternetAddress[] parseAddress(String personnel){ public static InternetAddress[] parseAddress(String personnel){
String addr=""; String addr="";
if("all".equals(personnel)){ if("all".equals(personnel)){
......
...@@ -260,48 +260,50 @@ public class ZipUtils { ...@@ -260,48 +260,50 @@ public class ZipUtils {
} }
} }
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
/** 测试压缩方法1 */ /** 测试压缩方法1 */
// FileOutputStream fos1 = new FileOutputStream(new File("c:/mytest01.zip")); // FileOutputStream fos1 = new FileOutputStream(new File("c:/mytest01.zip"));
// //
// ZipUtils.toZip("D:/log", fos1,true); // ZipUtils.toZip("D:/log", fos1,true);
/** 测试压缩方法2 */ /** 测试压缩方法2 */
List<File> fileList = new ArrayList<>(); // List<File> fileList = new ArrayList<>();
//
fileList.add(new File("F:\\gitCangKu\\Api_auto_test\\test-output\\html\\index.html")); // fileList.add(new File(mailpath+"index.html"));
fileList.add(new File("F:\\gitCangKu\\Api_auto_test\\test-output\\html\\overview.html")); // fileList.add(new File(mailpath+"overview.html"));
fileList.add(new File("F:\\gitCangKu\\Api_auto_test\\test-output\\html\\reportng.css")); // fileList.add(new File(mailpath+"reportng.css"));
fileList.add(new File("F:\\gitCangKu\\Api_auto_test\\test-output\\html\\reportng.js")); // fileList.add(new File(mailpath+"reportng.js"));
fileList.add(new File("F:\\gitCangKu\\Api_auto_test\\test-output\\html\\suite1_test1_results.html")); // fileList.add(new File(mailpath+"suite1_test1_results.html"));
fileList.add(new File("F:\\gitCangKu\\Api_auto_test\\test-output\\html\\suites.html")); // fileList.add(new File(mailpath+"suites.html"));
//
//
FileOutputStream fos2 = new FileOutputStream(new File("F:\\gitCangKu\\Api_auto_test\\test-output\\html\\mytest02.zip")); // FileOutputStream fos2 = new FileOutputStream(new File(mailpath+"mytest02.zip"));
//
ZipUtils.toZip(fileList, fos2); // ZipUtils.toZip(fileList, fos2);
} }
public static boolean ZipTestResult(){ public static boolean ZipTestResult(String mailpath){
List<File> fileList = new ArrayList<>(); List<File> fileList = new ArrayList<>();
fileList.add(new File("F:\\gitCangKu\\Api_auto_test\\test-output\\html\\index.html")); fileList.add(new File(mailpath+"index.html"));
fileList.add(new File("F:\\gitCangKu\\Api_auto_test\\test-output\\html\\overview.html")); fileList.add(new File(mailpath+"overview.html"));
fileList.add(new File("F:\\gitCangKu\\Api_auto_test\\test-output\\html\\reportng.css")); fileList.add(new File(mailpath+"reportng.css"));
fileList.add(new File("F:\\gitCangKu\\Api_auto_test\\test-output\\html\\reportng.js")); fileList.add(new File(mailpath+"reportng.js"));
fileList.add(new File("F:\\gitCangKu\\Api_auto_test\\test-output\\html\\suite1_test1_results.html")); fileList.add(new File(mailpath+"suite1_test1_results.html"));
fileList.add(new File("F:\\gitCangKu\\Api_auto_test\\test-output\\html\\suites.html")); fileList.add(new File(mailpath+"suites.html"));
FileOutputStream fos2=null; FileOutputStream fos2=null;
try { 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) { } catch (FileNotFoundException e) {
e.printStackTrace(); e.printStackTrace();
return false; 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