public void ReportProgress(TestingStatus status, int currentProgress, int maxProgress, string commandLine, string errorMessgae, string errorScreenshotPath, string testCase) { if (!string.IsNullOrEmpty(testCase)) { DataRow dr = _testCaseStatus.Rows[currentProgress]; dr["Status"] = status.ToString(); dr["Test Case"] = testCase; if (status == TestingStatus.LoadingApplications) { dr["Result"] = commandLine; dr["Exception"] = errorMessgae; dr["Image"] = errorScreenshotPath; } else if (status != TestingStatus.ExecutingTestCase && status != TestingStatus.ExecutingInnerTestCase) { dr["Result"] = string.IsNullOrEmpty(errorMessgae) ? "Passed" : "Failed"; dr["Exception"] = errorMessgae; dr["Image"] = errorScreenshotPath; } else { dr["Result"] = commandLine; } } if (TestingProgressChange != null) { TestingProgressChange(currentProgress, new ProgressChangeEvent { Status = status, CurrentProgress = status.ToString().Contains("TestCase") && !status.ToString().Contains("Inner") ? currentProgress + 1 : currentProgress, MaxProgress = maxProgress, CommandLine = commandLine, ErrorMessage = errorMessgae, ErrorScreenshotPath = errorScreenshotPath, TestCase = testCase }); } }
///<summary>Sets the value of the <c><TestingStatuses></c> element.</summary> /// <param name="TestingStatus">Records a single student-specific special condition before, during or after the test.</param> ///<remarks> /// <para>This form of <c>setTestingStatuses</c> is provided as a convenience method /// that is functionally equivalent to the <c>TestingStatuses</c></para> /// <para>Version: 2.6</para> /// <para>Since: 2.6</para> /// </remarks> public void SetTestingStatuses( TestingStatus TestingStatus ) { RemoveChild( AssessmentDTD.SIF3ASSESSMENTREGISTRATION_TESTINGSTATUSES); AddChild( AssessmentDTD.SIF3ASSESSMENTREGISTRATION_TESTINGSTATUSES, new TestingStatuses( TestingStatus ) ); }
public void ReportProgress(TestingStatus status, int currentProgress, int maxProgress, string commandLine, string testCase) { ReportProgress(status, currentProgress, maxProgress, commandLine, string.Empty, string.Empty, testCase); }
/// <summary> /// 开始测试。 /// </summary> /// <param name="groupName">要进行测试的测试组名。</param> /// <param name="keep">指示只执行一次测试,还是持续进行测试。</param> public void BeginTest(string groupName, bool keep) { // 开始进行测试 if (this.Config == null) throw new ArgumentNullException("Config"); var group = this.Config[ConfigKeys.TestingGroup] as TestingGroup; if (group == null) throw new ArgumentException("配置项缺乏 ConfigKeys.TestingGroup"); this.Status = TestingStatus.Running; ThreadPool.QueueUserWorkItem(status => { TestingConfiguration input = new TestingConfiguration(); foreach (var point in group.Points) { for (var i = 0; i < point.Times; ++i) { var item = Activator.CreateInstance(Type.GetType(point.Type)) as TestingItem; var data = new TestingData() { Config = this.Config, InputData = input != null ? new TestingConfiguration(point.Config.Concat(input).ToList()) : point.Config, Point = point, Time = i, Timeout = new TimeSpan(point.Timeout * 10000), StartTime = DateTime.Now }; this.OnTestingItemBegin(data); item.Test(data); this.OnTestingItemEnd(data); if (data.OutputData != null) { input.AddRange(data.OutputData); } } } this.Status = TestingStatus.Stop; }); }