/// <summary> /// constructor used by XMLRPC interface on decoding the function return /// </summary> /// <param name="data">data returned by Testlink</param> internal ExecutionResult(XmlRpcStruct data) { id = toInt(data, "id"); notes = (string)data["notes"]; execution_ts = toDate(data, "execution_ts"); execution_type = toInt(data, "execution_type"); build_id = toInt(data, "build_id"); tcversion_id = toInt(data, "tcversion_id"); tcversion_number = toInt(data, "tcversion_number"); status = toExecStatus(data, "status"); }
/// <summary> /// record a result with testlink; /// </summary> /// <param name="testCaseId"></param> /// <param name="status"></param> /// <param name="notes"></param> /// <returns></returns> public GeneralResult RecordTheResult(int testCaseId, TestCaseResultStatus status, string notes) { GeneralResult result = null; if (ConnectionValid == true) { result = proxy.ReportTCResult(testCaseId, testPlanId, status, platformName: platformName, notes: notes.ToString()); } else { result = new GeneralResult("Invalid Connection", false); } return(result); }
protected void PostTestResult(TestCaseResultStatus status) { try { tl.ReportTCResult( tl.GetTestCaseIDByName(TestName)[0].id, testPlanId, status, buildid: buildId); // it posts result for testcase. } catch (Exception ex) { // } }
/// <summary> /// after everything has been setup, record the actual result. /// </summary> /// <param name="result"></param> /// <param name="tlfa"></param> /// <param name="testPlanId"></param> /// <param name="TCaseId"></param> private void sendResultToTestlink(TestResult tcResult, TestLinkFixtureAttribute tlfa, int TCaseId) { TestCaseResultStatus status = TestCaseResultStatus.Blocked; StringBuilder notes = new StringBuilder(); notes.AppendLine(tcResult.Message); notes.AppendLine(currentTestOutput); switch (tcResult.ResultState) //RunState) { case ResultState.NotRunnable: status = TestCaseResultStatus.Blocked; break; case ResultState.Skipped: status = TestCaseResultStatus.Blocked; notes.AppendLine("++++ SKIPPED +++"); break; case ResultState.Ignored: status = TestCaseResultStatus.Blocked; notes.AppendLine("++++ IGNORED +++"); break; case ResultState.Success: status = TestCaseResultStatus.Pass; break; case ResultState.Failure: status = TestCaseResultStatus.Fail; break; case ResultState.Error: status = TestCaseResultStatus.Fail; break; } GeneralResult result = adaptor.RecordTheResult(TCaseId, status, notes.ToString()); if (result.status != true) { Console.WriteLine("Failed to export Result. Testlink reported: '{0}'", result.message); log.Warning(string.Format("Failed to export Result. Testlink reported: '{0}'", result.message)); } else { log.Info( string.Format("Reported Result (TCName=\"{0}\", TestPlan=\"{1}\", Status=\"{2}\").", tcResult.Name, tlfa.TestPlan, tcResult.ResultState.ToString())); } }
public static LogStatus ToExtentStatus(this TestCaseResultStatus status) { switch (status) { case TestCaseResultStatus.Pass: return(LogStatus.Pass); case TestCaseResultStatus.Exception: return(LogStatus.Fatal); case TestCaseResultStatus.Fail: return(LogStatus.Fail); case TestCaseResultStatus.Unexecuted: return(LogStatus.Skip); } return(LogStatus.Unknown); }
// private void recordResult(TestStepRun data, TestLinkFixtureAttribute tlfa, int testPlanId, int TCaseId) private void recordResult(Gallio.Runner.Reports.Schema.TestStepRun data, int TCaseId) { //Console.Write("2"); TestCaseResultStatus status = TestCaseResultStatus.Blocked;//= (data.Result.Outcome.Status == TestStatus.Passed) //? TestCaseResultStatus.Pass : TestCaseResultStatus.Fail; switch (data.Result.Outcome.Status) { case TestStatus.Passed: status = TestCaseResultStatus.Pass; break; case TestStatus.Failed: status = TestCaseResultStatus.Fail; break; case TestStatus.Skipped: status = TestCaseResultStatus.Blocked; break; case TestStatus.Inconclusive: status = TestCaseResultStatus.Blocked; break; } string notes = data.TestLog.ToString(); //Debug.WriteLine( // string.Format("ReportTCResult(TCName=\"{0}\", TestPlan=\"{1}\", Status=\"{2}\", Notes=\"{3}\"", // data.Step.Name, // tlfa.TestPlan, // (data.Result.Outcome.Status == TestStatus.Passed) ? "p" : "f", // notes)); //Console.Write("3"); GeneralResult reportResult = adaptor.RecordTheResult(TCaseId, status, notes);//proxy.ReportTCResult(TCaseId, testPlanId, status, notes); //Console.Write("4"); if (reportResult.status == true) { Console.WriteLine("Recorded test run result for {0} as {1}", data.Step.Name, data.Result.Outcome); } else { Console.Error.WriteLine(string.Format("recorded test result. status={0}, message ='{0}'", reportResult.status, reportResult.message)); } }
internal TestCaseFromTestPlan(XmlRpcStruct data) { active = int.Parse((string)data["active"]) == 1; name = (string)data["name"]; tsuite_name = (string)data["tsuite_name"]; z = toInt(data, "z"); type = (string)data["type"]; execution_order = toInt(data, "execution_order"); exec_id = toInt(data, "exec_id"); tc_id = toInt(data, "tc_id"); tcversion_number = toInt(data, "tcversion_number"); status = (string)data["status"]; external_id = (string)data["external_id"]; exec_status = toExecStatus(data, "exec_status"); exec_on_tplan = toInt(data, "exec_on_tplan"); executed = toInt(data, "executed"); feature_id = toInt(data, "feature_id"); assigner_id = toInt(data, "assigner_id"); user_id = toInt(data, "user_id"); active = toInt(data, "active") == 1; version = toInt(data, "version"); testsuite_id = toInt(data, "testsuite_id"); tcversion_id = toInt(data, "tcversion_id"); //steps = (string)data["steps"]; //expected_results = (string)data["expected_results"]; summary = (string)data["summary"]; execution_type = toInt(data, "execution_type"); platform_id = toInt(data, "platform_id"); platform_name = (string)data["platform_name"]; linked_ts = toDate(data, "linked_ts"); linked_by = toInt(data, "linked_by"); importance = toInt(data, "importance"); execution_run_type = (string)data["execution_run_type"]; execution_ts = (string)data["execution_ts"]; tester_id = toInt(data, "tester_id"); execution_notes = (string)data["execution_notes"]; exec_on_build = toInt(data, "exec_on_build"); assigned_build_id = toInt(data, "assigned_build_id"); urgency = toInt(data, "urgency"); priority = toInt(data, "priority"); }
/// <summary> /// record a result with testlink; /// </summary> /// <returns></returns> public GeneralResult RecordTheResult(string testName, string testSuite, TestCaseResultStatus status, string notes) { GeneralResult result = null; if (ConnectionValid == true) { int testCaseId = AddTestIfNotExisting(testName, testSuite); if (testCaseId == 0) { result = new GeneralResult("Unable to find/add testcase", false); } else { result = proxy.ReportTCResult(testCaseId, projectData.TestplanId, status, platformName: projectData.Platform, notes: notes.ToString(), buildid: projectData.BuildId); } } else { result = new GeneralResult("Invalid Connection", false); } return(result); }
protected void PostTestResult(TestCaseResultStatus status) { try { if (status == TestCaseResultStatus.Fail) { string expectedDate = DateTime.Now.ToString("yyyyMMddhhmmss"); Image image = UITestControl.Desktop.CaptureImage(); image.Save(Configs.ScreenshotPath + expectedDate + ".jpg"); TestContextInstance.AddResultFile(Configs.ScreenshotPath + expectedDate + ".jpg"); Debug.WriteLine("Screenshots attached " + (Configs.ScreenshotPath + expectedDate + ".jpg")); TestContext.WriteLine("Screenshots attached " + (Configs.ScreenshotPath + expectedDate + ".jpg")); } } catch (Exception ex) { Debug.WriteLine("screenshot failed"); Debug.WriteLine(ex.Message); TestContext.WriteLine("screenshot failed"); TestContext.WriteLine(ex.Message); } //try //{ // Tl.ReportTCResult(Tl.GetTestCaseIDByName(TestName)[0].id, TestPlanId, status, Configs.PlatformId, buildid: BuildId); // it posts result for testcase. //} //catch (Exception ex) //{ // Debug.WriteLine("Testlink report failed"); // Debug.WriteLine(ex.Message); // TestContext.WriteLine("Testlink report failed"); // TestContext.WriteLine(ex.Message); //} }
/// <summary> /// parse an execution status /// </summary> /// <param name="data"></param> /// <param name="name"></param> /// <returns></returns> internal TestCaseResultStatus toExecStatus(XmlRpcStruct data, string name) { TestCaseResultStatus result = TestCaseResultStatus.undefined; if (data.ContainsKey(name)) { char c = toChar(data, name); switch (c) { case 'f': case 'F': result = TestCaseResultStatus.Fail; break; case 'b': case 'B': result = TestCaseResultStatus.Blocked; break; case 'p': case 'P': result = TestCaseResultStatus.Pass; break; } } return(result); }
/// <summary> /// Record the outcome of a test case execution /// </summary> /// <param name="testcaseid">Id of test case</param> /// <param name="testplanid">Id of test plan</param> /// <param name="status">The result of the test (pass, fail or blocked)</param> /// <param name="platformId">Id of the platform. Optional if platform name is given</param> /// <param name="platformName">name of the platform. Optional if the platform id is given</param> /// <param name="overwrite">if true, then last execution for (testcase,testplan,build,platform) will be overwritten.</param> /// <param name="guess"> (assumed to be true) defining whether to guess optinal params or require them explicitly default is true</param> /// <param name="notes">any notes or info to be added to the description field</param> /// <param name="buildid">If not given, then highest build id willl be used</param> /// <param name="bugid">Id for a bug if used in conjunction with a defect tracker</param> /// <returns></returns> public GeneralResult ReportTCResult(int testcaseid, int testplanid, TestCaseResultStatus status, int platformId = 0, string platformName = null, bool overwrite = false, bool guess = true, string notes = "", int buildid = 0, int bugid = 0) { stateIsValid(); string statusChar = ""; switch (status) { case TestCaseResultStatus.Blocked: statusChar = "b"; break; case TestCaseResultStatus.Pass: statusChar = "p"; break; case TestCaseResultStatus.Fail: statusChar = "f"; break; } object response = null; if (platformName != null) { if (bugid == 0) { if (buildid == 0) response = proxy.reportTCResult(devkey, testcaseid, testplanid, statusChar, platformName, overwrite, notes, guess); else response = proxy.reportTCResult(devkey, testcaseid, testplanid, statusChar, platformName, overwrite, notes, guess, 0, buildid); } else { if (buildid == 0) response = proxy.reportTCResult(devkey, testcaseid, testplanid, statusChar, platformName, overwrite, notes, guess, bugid); else response = proxy.reportTCResult(devkey, testcaseid, testplanid, statusChar, platformName, overwrite, notes, guess, bugid, buildid); } } else { if (platformId == 0) throw new TestLinkException("must supply either a platform id or a platform name"); if (bugid == 0) { if (buildid == 0) response = proxy.reportTCResult(devkey, testcaseid, testplanid, statusChar, platformId, overwrite, notes, guess); else response = proxy.reportTCResult(devkey, testcaseid, testplanid, statusChar, platformId, overwrite, notes, guess, 0, buildid); } else { if (buildid == 0) response = proxy.reportTCResult(devkey, testcaseid, testplanid, statusChar, platformId, overwrite, notes, guess, bugid); else response = proxy.reportTCResult(devkey, testcaseid, testplanid, statusChar, platformId, overwrite, notes, guess, bugid, buildid); } } handleErrorMessage(response); //object response = proxy.reportTCResult(devkey, testcaseid, testplanid, statusChar, platformId, overwrite, notes, guess, buildid, bugid); //handleErrorMessage(response); return handleReportTCResult(response); }
internal TestCaseFromTestPlan(XmlRpcStruct data) { active = int.Parse((string)data["active"]) == 1; name = (string)data["name"]; tsuite_name = (string)data["tsuite_name"]; z = toInt(data, "z"); type = (string)data["type"]; execution_order = toInt(data, "execution_order"); exec_id = toInt(data, "exec_id"); tc_id = toInt(data, "tc_id"); tcversion_number = toInt(data, "tcversion_number"); status = (string)data["status"]; external_id = (string)data["external_id"]; exec_status = toExecStatus(data, "exec_status"); exec_on_tplan = toInt(data, "exec_on_tplan"); executed = toInt(data, "executed"); feature_id = toInt(data, "feature_id"); assigner_id = toInt(data, "assigner_id"); user_id = toInt(data, "user_id"); active = toInt(data, "active") == 1; version = toInt(data, "version"); testsuite_id = toInt(data, "testsuite_id"); tcversion_id = toInt(data, "tcversion_id"); //steps = (string)data["steps"]; //expected_results = (string)data["expected_results"]; summary = (string)data["summary"]; execution_type = toInt(data, "execution_type"); platform_id = toInt(data, "platform_id"); platform_name = (string)data["platform_name"]; linked_ts = toDate(data, "linked_ts"); linked_by = toInt(data, "linked_by"); importance = toInt(data, "importance"); execution_run_type = (string)data["execution_run_type"]; execution_ts = (string)data["execution_ts"]; tester_id = toInt(data, "tester_id"); execution_notes = (string)data["execution_notes"]; exec_on_build = toInt(data, "exec_on_build"); assigned_build_id = toInt(data,"assigned_build_id"); urgency = toInt(data, "urgency"); priority = toInt(data, "priority"); }
public void RecordCase(string testCaseName, TestCaseResultStatus status, string message = "") { test = extent.StartTest(testCaseName); test.Log(status.ToExtentStatus(), message); extent.EndTest(test); }
/// <summary> /// record a result with testlink; /// </summary> /// <param name="testCaseId"></param> /// <param name="status"></param> /// <param name="notes"></param> /// <returns></returns> public GeneralResult RecordTheResult(int testCaseId, TestCaseResultStatus status, string notes) { GeneralResult result = null; if (ConnectionValid == true) result = proxy.ReportTCResult(testCaseId, testPlanId, status, platformName: platformName, notes: notes.ToString()); else result = new GeneralResult("Invalid Connection", false); return result; }