/**/ private void InsertRow(TestCaseStepInfo testStep) { const int indent = 8; try { var data = new TestResult { Description = testStep.StepDescription, KeywordName = testStep.KeywordName, Result = testStep.Result == 1 ? "Passed" : (testStep.Result == -1 ? "Failed" : "Not Executed"), TestCaseName = testStep.TestCaseName }; if (_testCase != data.TestCaseName) { if (!string.IsNullOrEmpty(_testCase)) { TestLog += LineBreak; } TestLog += LineBreak + string.Format(" Test Case: {0} {1}", ">>>", data.TestCaseName); _testCase = data.TestCaseName; } TestLog += LineBreak + GetColumn(data.Description, ColumnWidth1, indent) + GetColumn(data.KeywordName, ColumnWidth2) + GetColumn(data.Result, ColumnWidth3); // TbResult.ScrollToEnd(); } catch (Exception exception) { var m = exception.Message; throw new TestingException("Failed to insert test result log!"); } }
private void ProgressChangedEventHandler(TestCaseStepInfo testCaseStepInfo) { InsertRow(testCaseStepInfo); }
public static TestPlanInfo ReadTestPlan(string testPlanFile) { XSSFWorkbook xssfwb; using (FileStream file = new FileStream(testPlanFile, FileMode.Open, FileAccess.Read)) { xssfwb = new XSSFWorkbook(file); } ISheet sheet = xssfwb.GetSheetAt(0); //get the first sheet var testPlan = new TestPlanInfo(); var testCases = new List<TestCaseInfo>(); //read the plan name var planName = sheet.GetRow(0).GetCell(1).ToString(); testPlan.Name = planName; int row = 1; while (row <= sheet.LastRowNum) { if (sheet.GetRow(row) != null) //null is when the row only contains empty cells { var firstCellValue = sheet.GetRow(row).GetCell(0) != null ? sheet.GetRow(row).GetCell(0).ToString() : ""; //test if it's a new test case if (firstCellValue == "Test Case Name") { row++; string testCaseName = sheet.GetRow(row).GetCell(0).StringCellValue; string testCaseType = sheet.GetRow(row).GetCell(1) != null ? sheet.GetRow(row).GetCell(1).ToString() : ""; row++; //get max cell number (based on the second row and the number of defined parameters var maxCell = sheet.GetRow(row).LastCellNum; row++; //skip the test case header row and the "Test Case Name" row var steps = new List<TestCaseStepInfo>(); while (sheet.GetRow(row) != null) { if (sheet.GetRow(row).GetCell(1) != null && sheet.GetRow(row).GetCell(1).ToString() != String.Empty) { var descr = sheet.GetRow(row).GetCell(0) != null? sheet.GetRow(row).GetCell(0).ToString(): ""; var keywordName = sheet.GetRow(row).GetCell(1).ToString(); var keywordType = sheet.GetRow(row).GetCell(2) != null? sheet.GetRow(row).GetCell(2).ToString(): ""; var passCondition = sheet.GetRow(row).GetCell(3).ToString(); var failCondition = sheet.GetRow(row).GetCell(4).ToString(); var parameters = new List<string>(); for (int index = 5; index < maxCell; index++) { var value = sheet.GetRow(row).GetCell(index) != null? sheet.GetRow(row).GetCell(index).ToString(): ""; parameters.Add(value); } var step = new TestCaseStepInfo() { StepDescription = descr, KeywordName = keywordName, KeywordType = keywordType, PassCondition = passCondition, FailCondition = failCondition, Parameters = parameters }; steps.Add(step); } row++; } var testCase = new TestCaseInfo() { Name = testCaseName, Type = testCaseType, Steps = steps }; testCases.Add(testCase); } } row++; } testPlan.TestCases = testCases; return testPlan; }