Adding Description Field to Report Email

Class library usage, coding and language questions.
Posts: 11
Joined: Fri Nov 08, 2013 8:03 pm

Adding Description Field to Report Email

Post by QaTester » Fri Nov 08, 2013 8:24 pm


I would like to add the description of the test case to the logger when I send a report email.

Currently, the first line of the email is:
2013/11/08 10:30:45.840 INFO Test Test Case 'test_TestCase' started

and I would like it to say:
2013/11/08 10:30:45.840 INFO Test Test Case 'test_TestCase' started. Description: "A dummy test case used for the purposes of debugging email..."etc.etc

I tried debugging our MailLogger class, which builds the body of the email here:

Code: Select all

public void LogText(ReportLevel level, string category, string message, bool escape, IDictionary<string, string> metaInfos)
            mail.Body += string.Format("[{0}][{1, -7}][{2}]: {3}\n", GetTimeStamp(),
                                       level, category, message);
            String styleLevel = level.ToString().ToUpper();
            if(styleLevel.Equals("SUCCESS")) {
            	styleLevel = "<span class="+"pass"+">"+styleLevel+"</span>";
            else if(styleLevel.Equals("FAILURE") || styleLevel.Equals("ERROR")) {
            	styleLevel = "<span class="+"fail"+">"+styleLevel+"</span>";
            else if(styleLevel.Equals("WARN")) {
            	styleLevel = "<span class="+"warn"+">"+styleLevel+"</span>";

            string htmlMessage = escape ? System.Web.HttpUtility.HtmlEncode(message) : message;
            htmlText += String.Format("<tr><td>{0}</td><td>{1}</td><td>{2}</td><td class="+"msg"+">{3}</td></tr>", GetTimeStamp(), styleLevel, category, htmlMessage);

My problem is that I can't figure out where LogText()gets called from and how string message gets passed . The call stack only reveals three lines "MailLogger.LogText, External methods, and Program.Main". My suspicion is that LogText() gets called somewhere in "External methods" but clicking on it creates an alert: "You cannot switch to a function without symbols."

Please advise as to how to include the test cases description with the email.

User avatar
Support Team
Site Admin
Site Admin
Posts: 12169
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA

Re: Adding Description Field to Report Email

Post by Support Team » Tue Nov 12, 2013 3:33 pm

Hello QaTester,

The 'metaInfos' parameter of the LogText method could be used to log additional information.
Please take a look at this post: ... tml#p16483

Another way would be to add the description to your message.
You could get the description of your TestCase using the following method:
var description = TestCase.Current as TestCase;
Report.Info("Description: " + description.Comment.ToString());
Markus (T)