internal virtual void PrintTestCaseDescription(TextWriter writer, TestMethodLog newMethod) { WriteLine(writer, TestCaseDescriptionLine); //IDictionary temp = context.Test.Properties; PrintTestCaseDescriptionLine(writer, "Test number", newMethod.Number); PrintTestCaseDescriptionLine(writer, "Category", newMethod.Category); PrintTestCaseDescriptionLine(writer, "Bug", newMethod.Bug); PrintTestCaseDescriptionLine(writer, "Description", newMethod.Description); PrintTestCaseDescriptionLine(writer, "Test Class", newMethod.ClassName); PrintTestCaseDescriptionLine(writer, "Test method", newMethod.TestName); if (newMethod.Children != null && newMethod.Children.Count > 0) { foreach (var child in newMethod.Children) { PrintChildrenLog(writer, child); } } this.PrintTestCaseResult(writer, newMethod.Result); if (!string.IsNullOrEmpty(newMethod.Message)) { this.PrintTestCaseMessage(writer, newMethod.Message); } if (!string.IsNullOrEmpty(newMethod.Stacktrace)) { this.PrintTestCaseStackTrace(writer, newMethod.Stacktrace); } }
public void WriteToOutput(TextWriter writer, Log.ParamLogLevel logLevel = Log.ParamLogLevel.Fail) { PrintHeader(writer); PrintFixtureSetUp(writer); foreach(var item in testFixture.Children) { if(item is TestMethodLog ) { TestMethodLog method = (TestMethodLog)item; if(logLevel == Log.ParamLogLevel.Fail) { if (method.Result == TestStatus.Inconclusive.ToString() || method.Result == TestStatus.Failed.ToString()) { PrintChildrenLog(writer, item); } } else if(logLevel == Log.ParamLogLevel.Full) { PrintChildrenLog(writer, item); } } } PrintFixtureTearDown(writer); PrintSumary(writer); PrintFooter(writer); }
public virtual void LogTestCaseResult() { TestContext context = TestContext.CurrentContext; string methodFullName = context.Test.FullName; TestMethodLog currentMethod = null; if (testFixture.CurrentNode != null && testFixture.CurrentNode is TestMethodLog) { currentMethod = testFixture.CurrentNode as TestMethodLog; } else if(testFixture.CurrentNode != null && (testFixture.CurrentNode is Request)) { if (testFixture.CurrentNode.Parent is TestMethodLog) currentMethod = testFixture.CurrentNode.Parent as TestMethodLog; } if (currentMethod != null) { currentMethod.Result = context.Result.Outcome.Status.ToString(); //PrintTestCaseResult(context.Result.Outcome.Status.ToString()); if (!string.IsNullOrEmpty(context.Result.Message)) { currentMethod.Message = context.Result.Message; } if (!string.IsNullOrEmpty(context.Result.StackTrace)) { currentMethod.Stacktrace = context.Result.StackTrace; } testFixture.CurrentNode = currentMethod; } }
/// <summary> /// Testcase setup /// </summary> public virtual void LogTestCaseDescription() { TestContext context = TestContext.CurrentContext; //IDictionary temp = context.Test.Properties; StringBuilder categoryStr = new StringBuilder(string.Empty); string description = string.Empty; string className = string.Empty; string testName = string.Empty; string methodFullName = context.Test.FullName; string bug = string.Empty; TestMethodLog newMethod = null; if (context != null && context.Test != null) { newMethod = new TestMethodLog(); if (context.Test.Properties.ContainsKey(PropertyNames.Category)) { ArrayList categories = context.Test.Properties.Get(PropertyNames.Category) as ArrayList; if (categories != null && categories.Count > 0) { foreach (object item in categories) { categoryStr.Append(item).Append(","); } categoryStr.Remove(categoryStr.Length - 1, 1); } else { categoryStr.Append(context.Test.Properties.Get(PropertyNames.Category) as string); } } if (context.Test.Properties.ContainsKey(PropertyNames.Description)) { description = (string)context.Test.Properties.Get(PropertyNames.Description); } if (context.Test.Properties.ContainsKey(BugAttribute.PropertyName)) { bug = (string)context.Test.Properties.Get(BugAttribute.PropertyName); } methodFullName = context.Test.FullName; className = context.Test.ClassName; testName = context.Test.Name; newMethod.Number = context.Test.ID; newMethod.FullName = methodFullName; newMethod.Description = description; newMethod.Category = categoryStr.ToString(); newMethod.ClassName = className.ToString(); newMethod.TestName = testName; newMethod.Bug = bug; this.testFixture.Children.Add(newMethod); newMethod.Parent = testFixture; testFixture.CurrentNode = newMethod; } //PrintTestCaseDescription(PrintedMethods[methodFullName]); }
internal override void PrintTestCaseDescription(TextWriter writer, TestMethodLog newMethod) { //StringBuilder str = new StringBuilder(); if (isRequestUlOpen) { writer.WriteLine("</ul>"); writer.WriteLine("</li>"); isRequestUlOpen = false; } if (isTestCaseUlOpen) { writer.WriteLine("</ul>"); writer.WriteLine("</li>"); isTestCaseUlOpen = false; } string temp = "Testcase" + newMethod.Number; writer.WriteLine(string.Format("<li><input type=\"checkbox\" id=\"{0}\" /><label for=\"{0}\" title=\"{2}\" class=\"testcase\"><b>{1}</b></label>", temp, newMethod.Number + "." + newMethod.TestName, newMethod.Description)); writer.WriteLine("<ul>"); isTestCaseUlOpen = true; writer.WriteLine(string.Format("<li>{0}</li>", "<b>Category:</b> " + newMethod.Category)); writer.WriteLine(string.Format("<li>{0}</li>", "<b>Bug:</b> " + newMethod.Bug)); writer.WriteLine(string.Format("<li>{0}</li>", "<b>Description:</b> " + newMethod.Description)); if (newMethod.Children != null && newMethod.Children.Count > 0) { foreach (var child in newMethod.Children) { PrintChildrenLog(writer, child); } } this.PrintTestCaseResult(writer, newMethod.Result); if (!string.IsNullOrEmpty(newMethod.Message)) { this.PrintTestCaseMessage(writer, newMethod.Message); } if (!string.IsNullOrEmpty(newMethod.Stacktrace)) { this.PrintTestCaseStackTrace(writer, newMethod.Stacktrace); } //writer.Write(str); }