JavaMail Message Format optimization (from details to stats)

Source: Internet
Author: User
Tags naming convention

The previously expanded Ant-jmeter supports the HTML file format for message attachments as well as for message content.

Because the content format of the message is detailed information, that is, the intuitive display is case, but because of the increase in case, the message content is getting bigger!

The main thing is that the leaders are not looking at whether the execution of each case passes, but rather the overall pass rate of each module (all interface scenarios involved).

Development and testing students can see the specific failure of the case as well as the cause ~

therefore need to modify Mailtask class and JavaMail Class!!!

The main thing for Mailtask is to classify and classify (i.e. case) satisfying certain conditions.

The Mailtask class relative to the previous moving core code is as follows:

The naming convention for case I am currently asking for 2 articles:

That is, it contains the module keyword--so that it will accept the case and statistics!!!

The module name cannot be empty and module names are in front of the previous module keyword!!! such as Login Module

Specifically, the code for naming conventions is as follows:

if (Fulltitile.tolowercase (). Contains ("module") = =true= fulltitile.substring (0, Fulltitile.tolowercase (). IndexOf ("module")). Trim ();

Statistical rules:

Classification and statistics according to module value

The code is as follows:

if(Fulltitile.tolowercase (). Contains ("module") = =true) {Module= Fulltitile.substring (0,fulltitile.tolowercase (). IndexOf ("module") . Trim (); if(Data.get (Module) = =NULL) {Count= Count +1; Color= (count%2<1)?Color1:color2; //record timeTime = Integer.parseint (Line.split ("\" ") [1]); Entity entity=NewEntity (); if(Line.indexof ("s=\" true\ "")!=-1) {Entity.successnum=x 1; }Else{entity.failnum= 1;                        } data.put (Module, entity); }Else{                            //record timeTime + = Integer.parseint (Line.split ("\" ") [1]); Entity entity=Data.get (Module); if(Line.indexof ("s=\" true\ "")!=-1) {Entity.successnum+ = 1; }Else{entity.failnum+ = 1;                                                    } data.put (Module, entity);            }}}} br.close ();            Isr.close ();            Fis.close (); Iterator Iterator=Data.keyset (). iterator ();  while(Iterator.hasnext ()) {Module=(String) iterator.next (); Entity entity=Data.get (Module); Allsuccess+=Entity.successnum; Allfailure+=Entity.failnum; Casetotalnum=entity.successnum+entity.failnum;

After rewriting the edit HTML format:

The code is as follows:

String htmlstring = "<tr valign=\" top\ ">"            + "<th>Module</th>"            + "<th>totalnum</th > "            +" <th>PassNum</th> "            +" <th>FaliNum</th> "            +" <th>passrate</th > "            +" </tr> ";      

if(Casetotalnum = = 0) { rate= "0"; Htmlstring= htmlstring + "<tr valign=\" middle\ "style=\" background: "+color+"; line-height:2em;\ ">" + "<td                    Align=\ "Center\" > "+module+" </td> "+" <td align=\ "Center\" > "+casetotalnum+" </td> " + "<td align=\" Center\ ">" +entity.successnum+ "</td>" + "&LT;TD align=\" cen                    Ter\ "> +entity.failnum+" </td> "+" <td align=\ "Center\" > "+rate+" </td> " + "</tr>"; } Else{DecimalFormat DF=NewDecimalFormat ("0.00"); Rate= Df.format ((float) entity.successnum/(float) casetotalnum*100); Htmlstring= htmlstring + "<tr valign=\" middle\ "style=\" background: "+color+"; line-height:2em;\ ">" + "<td                    Align=\ "Center\" > "+module+" </td> "+" <td align=\ "Center\" > "+casetotalnum+" </td> " + "<td align=\" Center\ ">" +entity.successnum+ "</td>" + "&LT;TD align=\" cen                    Ter\ "> +entity.failnum+" </td> "+" <td align=\ "Center\" > "+rate+"%</td> " + "</tr>"; }

The JavaMail class code is as follows:

JavaMail Class code modified less, just modified the message HTML report template, relative increase and deletion of some keywords

The

HTML code is as follows:

Bp.setcontent ("<! DOCTYPE html> "+" htmlstring+ "</table></body>);   Mp.addbodypart (BP); 

SendMail adds total time-consuming parameter properties

To complete the package, send an email report as follows:

Another description:

Because the HTTP request was only counted before, the JDBC request was added, so the HTTP request would be counted.

Because the JDBC request is generated in the JTL file in the following format

<SampleT= "646"it= "0"LT= "633"CT= "0"TS= "1497606686753"s= "true"lb= "Jdbc Module Request table configuration precondition contenttype=19"RC= "$"RM= "OK"DT= "text"de= "UTF-8" by= "404"SC= "1"EC= "0"ng= "1"na= "1"HN= "Nj-zoe-yang4">

The HTTP request is generated in the JTL file in the following format:

<HttpsampleT= "614"it= "0"LT= "614"CT= " the"TS= "1497606687694"s= "true"lb= "Login Module login Interface get cookie correct parameter"RC= "$"RM= "OK"DT= "text"de= "Utf-8" by= "509"SC= "1"EC= "0"ng= "1"na= "1"HN= "Nj-zoe-yang4">

The code is modified as follows

while (line = Br.readline ()) = null) {
if (Line.indexof ("

Have a better HTML template Everyone can communicate with me, I html very dish ~ also do not want to contact ~

JavaMail Message Format optimization (from details to stats)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.