public void Write(TestCaseResult result) { // Header WriteHeader("Case {0} ({1})", result.TestCase.Id, result.TestCase.ShortDescription); WriteLine(""); // Result info WriteLine(" - Original url: {0}", result.TestCase.Url); WriteLine(" - Actual url: {0}", result.ActualUrl); WriteLine(" - Response code success: {0}", (result.ResponseCodeSuccess) ? "Passed" : "Failed"); WriteLine(" - Time taken: {0}", result.ResponseTime.ToString()); WriteLine(" - Success: {0}", (result.Success) ? "Passed" : "Failed"); if (!string.IsNullOrEmpty(result.Message)) WriteLine(" - Message: {0}", result.Message); // Positives WriteLine("Verify positives"); WriteLine(" - Success: {0}", (result.VerifyPositivesSuccess) ? "Passed" : "Failed"); WriteVerifies(result.VerifyPositiveResults); // Negatives WriteLine("Verify negatives"); WriteLine(" - Success: {0}", (result.VerifyNegativeSuccess) ? "Passed" : "Failed"); WriteVerifies(result.VerifyNegativeResults); }
public void Visit(TestCaseResult caseResult) { xmlWriter.WriteStartElement("test-case"); xmlWriter.WriteAttributeString("name", caseResult.Name); if (caseResult.Description != null) { xmlWriter.WriteAttributeString("description", caseResult.Description); } xmlWriter.WriteAttributeString("executed", caseResult.Executed.ToString()); if (caseResult.Executed) { xmlWriter.WriteAttributeString("success", caseResult.IsSuccess.ToString()); xmlWriter.WriteAttributeString("time", caseResult.Time.ToString("#####0.000", NumberFormatInfo.InvariantInfo)); xmlWriter.WriteAttributeString("asserts", caseResult.AssertCount.ToString()); WriteCategories(caseResult); WriteProperties(caseResult); if (caseResult.IsFailure) { if (caseResult.IsFailure) { xmlWriter.WriteStartElement("failure"); } else { xmlWriter.WriteStartElement("error"); } xmlWriter.WriteStartElement("message"); xmlWriter.WriteCData(EncodeCData(caseResult.Message)); xmlWriter.WriteEndElement(); xmlWriter.WriteStartElement("stack-trace"); if (caseResult.StackTrace != null) { xmlWriter.WriteCData(EncodeCData(StackTraceFilter.Filter(caseResult.StackTrace))); } xmlWriter.WriteEndElement(); xmlWriter.WriteEndElement(); } } else { WriteCategories(caseResult); WriteProperties(caseResult); xmlWriter.WriteStartElement("reason"); xmlWriter.WriteStartElement("message"); xmlWriter.WriteCData(caseResult.Message); xmlWriter.WriteEndElement(); xmlWriter.WriteEndElement(); } xmlWriter.WriteEndElement(); }
public void OnFinish(TestCaseResult result, ILogger logger) { if (result.Exception != null) { var aggregateException = result.Exception as AggregateException; var messages = aggregateException == null ? new[] { result.Exception.Message } : aggregateException.InnerExceptions.Select(_ => _.Message); result.Description.Root.Add(new XElement("ErrorMessage", messages.ToMultiLine())); } }
public static string GetCreateBugLinkForTest(PipelineConfiguration config, TestCaseResult testResult) { return(GetTestResultLink(config, testResult.TestRun?.Id, testResult.Id, new Dictionary <string, string> { { "create-bug", "true" } })); }
public void CheckInsert(TestCaseResult result) { DropTable(); CreateTable(); InsertRow(0); InsertRow(1); InsertRow(2); CheckTable(result); }
private void ReportFailureMessage(string messageValue) { var msg = new TestCaseResult(ResultType.Failed) { OtherInfo = messageValue, }; ReportIt(msg); }
public void Enlist(TestCaseResult result) { CheckDtcEnabled(result); XAction x = new XAction(); x.Enlist(connection); x.UnEnlist(connection); }
public void TestCaseCompleted(TestCaseResult result) { using (FileStream file = File.Open(_logFilename, FileMode.Append)) { using (var writer = new StreamWriter(file)) { writer.WriteLine((result.Passed ? "[ pass ]" : "[**FAIL**]") + result.Name + " in " + result.DurationOfTest); writer.Flush(); } } }
private async Task <List <TestCaseResult> > GatherTestRunTestCaseResult(int testRunId) { List <TestCaseResult> res = new List <TestCaseResult>(); var requestUri = "/APHP/" + _project + "/_apis/test/runs/" + testRunId + "/results?api-version=3.0"; var method = new HttpMethod("GET"); var request = new HttpRequestMessage(method, requestUri) { }; var response = await _client.SendAsync(request); _logger.Log(requestUri); string responseTxt = await response.Content.ReadAsStringAsync(); _logger.Log(responseTxt); if (response.IsSuccessStatusCode) { JObject jo = JObject.Parse(responseTxt); foreach (JToken testCaseResult in jo["value"]) { TestCaseResult currTestCaseResult = new TestCaseResult(); if (testCaseResult["outcome"] != null) { currTestCaseResult.Result = testCaseResult["outcome"].ToString(); } else { currTestCaseResult.Result = "In Progress"; } if (testCaseResult["completedDate"] != null) { DateTime tempTime = DateTime.Parse(testCaseResult["completedDate"].ToString()); currTestCaseResult.ResultDT = tempTime.AddHours(-6.0); } if (testCaseResult["runBy"] != null) { currTestCaseResult.RunByName = testCaseResult["runBy"]["displayName"].ToString(); } currTestCaseResult.TestCaseId = Convert.ToInt32(testCaseResult["testCase"]["id"]); currTestCaseResult.TestRunId = testRunId; res.Add(currTestCaseResult); } } else { throw new Exception(); } return(res); }
public override void OnTestCaseExecutionComplete(TestCase testCase, TestCaseResult testCaseResult) { //throwException(); int time = 500; Thread.Sleep(time); LogEvent.Debug($"{MethodInfo.GetCurrentMethod().Name} {testCaseResult.VirtualUser}, sleep time: {time}"); }
private void CheckTransactionCapable(TestCaseResult result) { String host = TestSettings.GetString("HOST"); if (host != null && host.StartsWith(":in-process:")) { result.Skip("Transaction tests are disabled for in-process client."); } }
private static void PrintTestCaseResult(TestCaseResult result) { Console.WriteLine("\n"); Console.WriteLine("----------------------------------------------"); Console.WriteLine(result.TestCaseName); Console.WriteLine($"Average test runtime {result.AverageRunTimePerIteration}ms"); Console.WriteLine($"Total test runtime {result.TotalRunTime}ms"); Console.WriteLine($"Number of time test was ran: {result.NumberOfIterationsOfTest}"); }
public void Handle(TestCaseResult message) { if (message == null) { throw new ArgumentNullException("message"); } switch (message.ResultType) { case ResultType.Ignored: "I".WrapConsoleMessageWithColor(_settings.ConsoleColorInformatoin, false); break; case ResultType.Passed: ".".WrapConsoleMessageWithColor(_settings.ConsoleColorInformatoin, false); break; case ResultType.Failed: case ResultType.SystemGeneratedFailure: System.Console.WriteLine(""); "------------------ ".WrapConsoleMessageWithColor(_settings.ConsoleColorError, false); "Test ".WrapConsoleMessageWithColor(_settings.ConsoleColorError, false); "Failed".WrapConsoleMessageWithColor(_settings.ConsoleColorError, false); " ------------------".WrapConsoleMessageWithColor(_settings.ConsoleColorError, true); "Test Namespace: ".WrapConsoleMessageWithColor(_settings.ConsoleColorInformatoin, false); message.NamespaceName.WrapConsoleMessageWithColor(_settings.ConsoleColorError, true); "Test Class: ".WrapConsoleMessageWithColor(_settings.ConsoleColorInformatoin, false); message.ClassName.WrapConsoleMessageWithColor(_settings.ConsoleColorError, true); "Test Method: ".WrapConsoleMessageWithColor(_settings.ConsoleColorInformatoin, false); message.MethodName.WrapConsoleMessageWithColor(_settings.ConsoleColorError, true); if (!string.IsNullOrEmpty(message.OtherInfo)) { "Other Info: ".WrapConsoleMessageWithColor(_settings.ConsoleColorInformatoin, false); message.OtherInfo.WrapConsoleMessageWithColor(_settings.ConsoleColorError, true); } if (message.ExceptionInfo != null) { //TODO: print to the console - the exception info in a more readable/visually parsable format "Exception Message: ".WrapConsoleMessageWithColor(_settings.ConsoleColorInformatoin, true); message.ExceptionInfo.FullMessage.WrapConsoleMessageWithColor(_settings.ConsoleColorError, true); } "-------------------------------------------------" .WrapConsoleMessageWithColor(ConsoleColor.DarkRed, true); break; default: "Unknown TestCaseResult (to StatLight) - {0}".FormatWith(message.ResultType) .WrapConsoleMessageWithColor(_settings.ConsoleColorError, true); break; } }
public void MultipleResultSets(TestCaseResult result) { DropProcedure(); ExecuteNonQuery( "create procedure bar ()\n" + "{\n" + " declare i int;\n" + " declare c char;\n" + " result_names (i);\n" + " result (1);\n" + " result (2);\n" + " end_result ();\n" + " result_names (c);\n" + " result ('a');\n" + " result ('b');\n" + " return 0;\n" + "}\n" ); VirtuosoCommand command = connection.CreateCommand(); command.CommandType = CommandType.StoredProcedure; command.CommandText = "bar"; VirtuosoDataReader reader = null; try { reader = command.ExecuteReader(); result.FailIfNotEqual(1, reader.FieldCount); result.FailIfNotEqual("i", reader.GetName(0).ToLower()); result.FailIfNotEqual(typeof(int), reader.GetFieldType(0)); result.FailIfNotEqual(true, reader.Read()); result.FailIfNotEqual(1, reader["i"]); result.FailIfNotEqual(true, reader.Read()); result.FailIfNotEqual(2, reader["i"]); result.FailIfNotEqual(false, reader.Read()); result.FailIfNotEqual(true, reader.NextResult()); result.FailIfNotEqual(1, reader.FieldCount); result.FailIfNotEqual("c", reader.GetName(0).ToLower()); result.FailIfNotEqual(typeof(string), reader.GetFieldType(0)); result.FailIfNotEqual(true, reader.Read()); result.FailIfNotEqual("a", reader["c"]); result.FailIfNotEqual(true, reader.Read()); result.FailIfNotEqual("b", reader["c"]); result.FailIfNotEqual(false, reader.NextResult()); } finally { if (reader != null) { reader.Close(); } command.Dispose(); } }
private async Task UploadTestResultsAttachmentAsync(int testRunId, TestCaseResultData testCaseResultData, TestCaseResult testCaseResult, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); if (testCaseResult == null || testCaseResultData == null) { return; } if (testCaseResultData.AttachmentData != null) { // Remove duplicate entries string[] attachments = testCaseResultData.AttachmentData.AttachmentsFilePathList?.ToArray(); HashSet <string> attachedFiles = GetUniqueTestRunFiles(attachments); if (attachedFiles != null && attachedFiles.Any()) { var createAttachmentsTasks = attachedFiles.Select(async attachment => { TestAttachmentRequestModel reqModel = GetAttachmentRequestModel(attachment); if (reqModel != null) { await _testResultsServer.CreateTestResultAttachmentAsync(reqModel, _projectName, testRunId, testCaseResult.Id, cancellationToken); } }); await Task.WhenAll(createAttachmentsTasks); } // Upload console log as attachment string consoleLog = testCaseResultData?.AttachmentData.ConsoleLog; TestAttachmentRequestModel attachmentRequestModel = GetConsoleLogAttachmentRequestModel(consoleLog); if (attachmentRequestModel != null) { await _testResultsServer.CreateTestResultAttachmentAsync(attachmentRequestModel, _projectName, testRunId, testCaseResult.Id, cancellationToken); } // Upload standard error as attachment string standardError = testCaseResultData.AttachmentData.StandardError; TestAttachmentRequestModel stdErrAttachmentRequestModel = GetStandardErrorAttachmentRequestModel(standardError); if (stdErrAttachmentRequestModel != null) { await _testResultsServer.CreateTestResultAttachmentAsync(stdErrAttachmentRequestModel, _projectName, testRunId, testCaseResult.Id, cancellationToken); } } if (testCaseResult.SubResults != null && testCaseResult.SubResults.Any() && testCaseResultData.TestCaseSubResultData != null) { for (int i = 0; i < testCaseResultData.TestCaseSubResultData.Count; i++) { await UploadTestSubResultsAttachmentAsync(testRunId, testCaseResult.Id, testCaseResultData.TestCaseSubResultData[i], testCaseResult.SubResults[i], 1, cancellationToken); } } }
public void TestFinished(TestCaseResult testCaseResult) { UpdateTestInfo(testCaseResult); if (testCaseResult.Executed && testCaseResult.IsFailure) { ReportTestFailureInfo(testCaseResult); } m_testProgressInfo.CurrentTestName = string.Empty; }
public override void OnTestCaseExecutionComplete(TestCase testCase, TestCaseResult testCaseResult) { string padding = getPadding(testObjectDictionary[testCase.SystemID]); using (StreamWriter sw = File.AppendText(resultFile)) { sw.WriteLine(string.Format("{0}Start Time: {1}, End Time: {2}, Duration: {3}.", padding, testCaseResult.StartTime.ToString("T", null), testCaseResult.EndTime.ToString("T", null), testCaseResult.ElapsedTime)); } }
private async Task <List <TestCaseResult> > GatherResultsInRun(TestRun testRun) { List <TestCaseResult> res = new List <TestCaseResult>(); var requestUri = "/APHP/" + _project + "/_apis/test/runs/" + testRun.TestRunId + "/results?api-version=3.0"; var method = new HttpMethod("GET"); var request = new HttpRequestMessage(method, requestUri) { }; var response = await _client.SendAsync(request); if (response.IsSuccessStatusCode) { string responseString = await response.Content.ReadAsStringAsync(); var jo = JObject.Parse(responseString); foreach (JToken testResult in jo["value"]) { int testRunId = Convert.ToInt32(testResult["id"]); int testCaseId = Convert.ToInt32(testResult["testCase"]["id"]); TestCaseResult currTestCaseResult = null; string testOutcome = null; DateTime testDateTime = default(DateTime); if (testResult["outcome"] != null) { currTestCaseResult = new TestCaseResult(); testOutcome = testResult["outcome"].ToString(); testDateTime = DateTime.Parse(testResult["completedDate"].ToString()); currTestCaseResult.RunByName = testResult["runBy"]["displayName"].ToString(); currTestCaseResult.TestRunId = testRun.TestRunId; currTestCaseResult.ResultDT = testDateTime; currTestCaseResult.Result = testResult["outcome"].ToString(); } if (currTestCaseResult != null) { if (!_testCaseIdToResults.ContainsKey(testCaseId)) { _testCaseIdToResults[testCaseId] = new List <TestCaseResult> { currTestCaseResult }; } else { _testCaseIdToResults[testCaseId].Add(currTestCaseResult); } res.Add(currTestCaseResult); } } } return(res); }
public static IEnumerable <string> ReadMetadata(this TestCaseResult testCaseResult, string property) { var data = testCaseResult.Metadata.Where(w => w.Name == property); if (data.Any()) { return(data.Select(s => s.Value)); } return(null); }
public void RollbackNoWork(TestCaseResult result) { CheckTransactionCapable(result); CheckTable(result); VirtuosoTransaction t = connection.BeginTransaction(); result.FailIfNotSame(connection, t.Connection); t.Rollback(); CheckTable(result); }
public void SetResult_Skipped() { TestSuiteTreeNode node = new TestSuiteTreeNode(testCaseInfo); TestCaseResult result = new TestCaseResult(testCaseInfo); result.RunState = RunState.Skipped; node.Result = result; Assert.AreEqual(TestSuiteTreeNode.SkippedIndex, node.ImageIndex); Assert.AreEqual(TestSuiteTreeNode.SkippedIndex, node.SelectedImageIndex); Assert.AreEqual("Skipped", node.StatusText); }
public void Equality_DifferentMethod() { var a = new TestCaseResult { TestMethod = Names.Method("[T,P] [T,P].M()") }; var b = new TestCaseResult(); Assert.AreNotEqual(a, b); Assert.AreNotEqual(a.GetHashCode(), b.GetHashCode()); }
public void SetResult_Init() { TestSuiteTreeNode node = new TestSuiteTreeNode(testCaseInfo); TestCaseResult result = new TestCaseResult(testCaseInfo); node.Result = result; Assert.AreEqual("NUnit.Tests.Assemblies.MockTestFixture.MockTest1", node.Result.Name); Assert.AreEqual(TestSuiteTreeNode.InitIndex, node.ImageIndex); Assert.AreEqual(TestSuiteTreeNode.InitIndex, node.SelectedImageIndex); Assert.AreEqual("Runnable", node.StatusText); }
public void Equality_DifferentDuration() { var a = new TestCaseResult { Duration = TimeSpan.FromSeconds(3) }; var b = new TestCaseResult(); Assert.AreNotEqual(a, b); Assert.AreNotEqual(a.GetHashCode(), b.GetHashCode()); }
public void Equality_DifferentResult() { var a = new TestCaseResult { Result = TestResult.Success }; var b = new TestCaseResult(); Assert.AreNotEqual(a, b); Assert.AreNotEqual(a.GetHashCode(), b.GetHashCode()); }
public void Equality_DifferentStartTime() { var a = new TestCaseResult { StartTime = _someDateTime }; var b = new TestCaseResult(); Assert.AreNotEqual(a, b); Assert.AreNotEqual(a.GetHashCode(), b.GetHashCode()); }
public void Equality_DifferentParameters() { var a = new TestCaseResult { Parameters = "p" }; var b = new TestCaseResult(); Assert.AreNotEqual(a, b); Assert.AreNotEqual(a.GetHashCode(), b.GetHashCode()); }
public void SetResult_Success() { TestSuiteTreeNode node = new TestSuiteTreeNode(testCaseInfo); TestCaseResult result = new TestCaseResult(testCaseInfo); result.Success(); node.Result = result; Assert.AreEqual(TestSuiteTreeNode.SuccessIndex, node.ImageIndex); Assert.AreEqual(TestSuiteTreeNode.SuccessIndex, node.SelectedImageIndex); Assert.AreEqual("Success", node.StatusText); }
public void SetResult_Failure() { TestSuiteTreeNode node = new TestSuiteTreeNode(testCaseInfo); TestCaseResult result = new TestCaseResult(testCaseInfo); result.Failure("message", "stacktrace"); node.Result = result; Assert.AreEqual(TestSuiteTreeNode.FailureIndex, node.ImageIndex); Assert.AreEqual(TestSuiteTreeNode.FailureIndex, node.SelectedImageIndex); Assert.AreEqual("Failure", node.StatusText); }
private static CustomTestField GetCustomField(this TestCaseResult result, string fieldName) { if (result.CustomFields == null) { return(null); } var cf = result.CustomFields.FirstOrDefault(c => c.FieldName.Equals(fieldName, StringComparison.OrdinalIgnoreCase)); return(cf); }
public override void Run(TestCaseResult result) { // So testCase can get the fixture testCase.Parent = this.Parent; for( int i = 0; i < count; i++ ) { testCase.Run( result ); if ( result.IsFailure ) return; } }
public override void Run(TestCaseResult result) { base.Run( result ); if ( result.IsSuccess && !ExceptionExpected ) { int elapsedTime = (int)(result.Time * 1000); if ( elapsedTime > maxTime && !expectFailure) result.Failure( string.Format( "Elapsed time of {0}ms exceeds maximum of {1}ms", elapsedTime, maxTime ), null ); else if ( elapsedTime <= maxTime && expectFailure ) result.Failure( "Expected a timeout failure, but none occured", null ); } }
public void TableUpdate(TestCaseResult result) { DropTable(); CreateTable(); InsertRow(1); InsertRow(2); DataSet dataset = new DataSet(); VirtuosoDataAdapter adapter = null; VirtuosoCommandBuilder builder = null; try { adapter = new VirtuosoDataAdapter(); adapter.SelectCommand = new VirtuosoCommand("select * from foo", connection); adapter.Fill(dataset, "table"); builder = new VirtuosoCommandBuilder(); builder.DataAdapter = adapter; DataTable table = dataset.Tables["table"]; if (table.Rows.Count > 0) { DataRow row = table.Rows[0]; row.Delete(); } //if (table.Rows.Count > 1) //{ // DataRow row = table.Rows[1]; // row["j"] = 555; // row["s"] = "bbb"; //} DataRow newrow = table.NewRow(); newrow["i"] = 3; newrow["n"] = 333; table.Rows.Add(newrow); adapter.Update(dataset, "Table"); } finally { if (builder != null) { builder.Dispose(); builder = null; } if (adapter != null) { adapter.Dispose(); adapter = null; } } }
protected override void Because() { base.Because(); TestResultAggregator.Handle(new TestExecutionMethodBeginClientEvent { ClassName = "Class name test", MethodName = "method name test", NamespaceName = "namespace test", }); TestResultAggregator.Handle(_testExecutionMethodPassedClientEvent); _passedResult = TestResultAggregator .CurrentReport .TestResults.Where(w => w.ResultType == ResultType.Passed) .Cast<TestCaseResult>() .FirstOrDefault(); }
public void TestFinished(TestCaseResult result) { testCaseFinished++; }
private void Initialize(bool create = true) { if (create) { _expectedResult = TestCaseResult.Passed; _runState = TestRunState.NotStarted; this.LogMessages = new ObservableCollection<string>(); _postValues = new ObservableCollection<PostRunPairs>(); } }
public void TestFinished(TestCaseResult result) { foreach( EventListener listener in extensions ) listener.TestFinished( result ); }
public void TestFinished(TestCaseResult result) { testFinished.Add(result.Name); lastResult = result; }
protected override void Because() { base.Because(); TestResultAggregator.Handle(new TestExecutionMethodBeginClientEvent { NamespaceName = "n", ClassName = "c", MethodName = "m0" }); TestResultAggregator.Handle(new TestExecutionMethodPassedClientEvent { NamespaceName = "n", ClassName = "c", MethodName = "m0" }); TestResultAggregator.Handle(new DialogAssertionServerEvent(DialogType.MessageBox) { Message = "some message here" }); _manufacturedFailedEvent = _manufacturedFailedEvents.FirstOrDefault(); }
public void Visit(TestCaseResult caseResult) { if(caseResult.Name.Equals(name)) Assert.AreEqual(description, caseResult.Description); }
public void Write(TestCaseResult result) { }