/// <summary> /// Collect info about the class And the method that threw the assertion error /// </summary> /// <returns></returns> private static string MessageType(MessageType type, ReportLine reportLine) { string messageType = ""; switch (type) { case JPB_Framework.Report.MessageType.AssertionError: { messageType = "Assertion error"; reportLine.Error = true; CaseFailed = true; break; } case JPB_Framework.Report.MessageType.VerificationError: { messageType = "Verification error"; reportLine.Error = true; CaseFailed = true; break; } case JPB_Framework.Report.MessageType.Exception: { messageType = "Exception thrown"; reportLine.Error = true; CaseFailed = true; break; } case JPB_Framework.Report.MessageType.Message: { messageType = "Message"; break; } case JPB_Framework.Report.MessageType.Empty: { messageType = ""; break; } } return(messageType); }
/// <summary> /// Output message to report file. /// </summary> /// <param name="type"> Message type</param> /// <param name="message"> Message to write to report file</param> /// <param name="e"></param>> public static void ToLogFile(MessageType type, string message, Exception e) { var reportLine = new ReportLine(); reportLine.Date = DateTime.Now.ToShortDateString(); reportLine.Time = DateTime.Now.ToLongTimeString(); if (type != JPB_Framework.Report.MessageType.Empty) { reportLine.Step = MessageType(type, reportLine); reportLine.Message = message; if (type == JPB_Framework.Report.MessageType.Exception) { reportLine.Message = $"{reportLine.Message} {e.Message} {e.StackTrace}"; } else { var stack = new StackTrace(true); var frame = stack.GetFrame(2); var reflectedType = frame.GetMethod().ReflectedType; if (reflectedType != null) { reportLine.Class = reflectedType.FullName; } reportLine.Method = frame.GetMethod().Name; reportLine.Line = frame.GetFileLineNumber().ToString(); } } else { reportLine.Step = message; reportLine.Message = ""; reportLine.Class = ""; reportLine.Method = ""; reportLine.Line = ""; } TestCaseReportLines.Add(reportLine); }
/// <summary> /// Collect info about the class And the method that threw the assertion error /// </summary> /// <returns></returns> private static string MessageType(MessageType type, ReportLine reportLine) { string messageType = ""; switch (type) { case JPB_Framework.Report.MessageType.AssertionError: { messageType = "Assertion error"; reportLine.Error = true; break; } case JPB_Framework.Report.MessageType.VerificationError: { messageType = "Verification error"; reportLine.Error = true; break; } case JPB_Framework.Report.MessageType.Exception: { messageType = "Exception thrown"; reportLine.Error = true; break; } case JPB_Framework.Report.MessageType.Message: { messageType = "Message"; break; } case JPB_Framework.Report.MessageType.Empty: { messageType = ""; break; } } return messageType; }
/// <summary> /// Output message to report file. /// </summary> /// <param name="type"> Message type</param> /// <param name="message"> Message to write to report file</param> /// <param name="e"></param>> public static void ToLogFile(MessageType type, string message, Exception e) { var reportLine = new ReportLine(); reportLine.Date = DateTime.Now.ToShortDateString(); reportLine.Time = DateTime.Now.ToLongTimeString(); if (type != JPB_Framework.Report.MessageType.Empty) { reportLine.Step = MessageType(type, reportLine); reportLine.Message = message; if (type == JPB_Framework.Report.MessageType.Exception) { reportLine.Message = $"{reportLine.Message} {e.Message} {e.StackTrace}"; } else { var stack = new StackTrace(true); var frame = stack.GetFrame(2); var reflectedType = frame.GetMethod().ReflectedType; if (reflectedType != null) reportLine.Class = reflectedType.FullName; reportLine.Method = frame.GetMethod().Name; reportLine.Line = frame.GetFileLineNumber().ToString(); } } else { reportLine.Step = message; reportLine.Message = ""; reportLine.Class = ""; reportLine.Method = ""; reportLine.Line = ""; } TestCaseReportLines.Add(reportLine); }