コード例 #1
0
        public Task <bool> AddAsync(IEnumerable <TestCaseInfo> items)
        {
            Task <bool> newTask = new Task <bool>(() =>
            {
                string assemblyFolder             = this.configurationManager.GetConfigValue(Constants.TestAssembliesFolder);
                IEnumerable <string> testAssembly = (from r in items select r.Source).Distinct(StringComparer.InvariantCultureIgnoreCase);
                testAssembly = this.CopyFile(testAssembly);
                foreach (TestCaseInfo testCase in items)
                {
                    string orignalSource = Path.GetFileName(testCase.Source);
                    testCase.Source      = Path.Combine(assemblyFolder, orignalSource, orignalSource);
                    if (!this.methodInfos.Contains(testCase))
                    {
                        this.methodInfos.Add(testCase);
                    }
                }

                string output = TestCaseInfo.SerializeList(this.methodInfos);
                File.WriteAllText(defaultReposFile, output, this.configurationManager.GetEncoding());

                return(true);
            });

            newTask.Start();
            return(newTask);
        }
コード例 #2
0
            /// <summary>
            /// Creates a set of test cases for specified dimensions.
            /// </summary>
            /// <param name="dimensions">
            /// An array which contains information about dimensions. Each element of
            /// this array represents a number of features in the specific dimension.
            /// </param>
            /// <returns>
            /// A set of test cases.
            /// </returns>
            public List <TestCaseInfo> GetTestCases(int[] dimensions)
            {
                this.prng       = new FleaRand(15485863);
                this.dimensions = dimensions;

                this.CreateAllTuples();

                List <TestCaseInfo> testCases = new List <TestCaseInfo>();

                while (true)
                {
                    FeatureTuple tuple = this.GetNextTuple();

                    if (tuple == null)
                    {
                        break;
                    }

                    TestCaseInfo testCase = this.CreateTestCase(tuple);

                    this.RemoveTuplesCoveredByTest(testCase);

                    testCases.Add(testCase);
                }

                return(testCases);
            }
コード例 #3
0
        /// <summary>
        /// The finish reporting.
        /// </summary>
        /// <param name="executionObject">
        /// The execution object.
        /// </param>
        /// <param name="testCaseInfo">
        /// The test Case Info.
        /// </param>
        public static void FinishReporting(ref ExecutionObject executionObject, ref TestCaseInfo testCaseInfo)
        {
            Log.Enter(LogInfo.Namespace(MethodBase.GetCurrentMethod()), MethodBase.GetCurrentMethod().Name);

            try
            {
                testCaseInfo.TestCaseName   = currentTestCase; // executionObject.TestCaseName;
                testCaseInfo.TestCasePath   = executionObject.ReportFolderTestCases;
                testCaseInfo.TestCaseResult = (TestResult)TestReport.CurrentTestModuleActivity.Status;
                executionObject.CurrentTestReportInfo.TestCaseInfos.Add(testCaseInfo);

                // Finish testcase logfile
                TestReport.EndTestModule();
                TestReport.SetCurrentTestResult(testCaseInfo.TestCaseResult);
                TestReport.EndTestCase();
                TestReport.SetCurrentTestResult(testCaseInfo.TestCaseResult);
                TestReport.EndTestCaseSetup();
                TestReport.SetCurrentTestResult(testCaseInfo.TestCaseResult);
                TestReport.SaveReport();
                TestReport.Clear();
            }
            catch (Exception exception)
            {
                Log.Enter(LogInfo.Namespace(MethodBase.GetCurrentMethod()), exception.Message);
            }
        }
コード例 #4
0
        private void CheckBox_CheckAll(object sender, RoutedEventArgs e)
        {
            this.testMethodListViewModel.TestMethodsSelectChangedCommand.Execute(null);
            CheckBox checkBox = sender as CheckBox;

            if (checkBox?.IsChecked == true)
            {
                foreach (object o in this.TestMethodList.Items)
                {
                    TestCaseInfo testCase = o as TestCaseInfo;
                    if (testCase.Status != TestOutcome.NotFound && testCase.Status != TestOutcome.Skipped)
                    {
                        testCase.Selected = true;
                    }
                }
            }
            else if (checkBox?.IsChecked == false)
            {
                foreach (object o in this.TestMethodList.Items)
                {
                    TestCaseInfo testCase = o as TestCaseInfo;
                    if (testCase.Status != TestOutcome.NotFound && testCase.Status != TestOutcome.Skipped)
                    {
                        testCase.Selected = false;
                    }
                }
            }

            this.TestMethodCollectionView.View.Refresh();
        }
コード例 #5
0
        public void SelectedItemChanged(object selectedItem)
        {
            TestProjectShip testProject = selectedItem as TestProjectShip;

            if (testProject != null)
            {
                this.eventAggregator.GetEvent <TestProjectSelectedEvent>().Publish(testProject.TestProjectInfo);
                return;
            }

            TestAssembly assembly = selectedItem as TestAssembly;

            if (assembly != null)
            {
                this.eventAggregator.GetEvent <TestAssemblySelectedEvent>().Publish(assembly);
                return;
            }

            TestCaseInfo testCase = selectedItem as TestCaseInfo;

            if (testCase != null)
            {
                this.eventAggregator.GetEvent <TestMethodSelectedEvent>().Publish(testCase);
                return;
            }
        }
コード例 #6
0
ファイル: TestNameTests.cs プロジェクト: Carbonfrost/f-spec
 public TestUnitDisplayNameData Data(TestCaseInfo unit, string name)
 {
     return(new TestUnitDisplayNameData {
         Unit = unit,
         Name = name,
     });
 }
コード例 #7
0
        public bool Generate(TestCaseInfo testcaseinfo,string logDirectory)
        {
            DateTime endTime = DateTime.Now;
            testcaseinfo.EndTime=endTime;
            try
            {
                XmlDocument document = new XmlDocument();
                XmlElement testRun = document.CreateElement("TestRun");
                document.AppendChild(testRun);
                string runId = Guid.NewGuid().ToString(); ;
                testRun.SetAttribute("id", runId);
                string time =testcaseinfo.StartTime.ToString(_timeFormat);
                testRun.SetAttribute("StartTime", testcaseinfo.StartTime.ToString(_timeFormat));
                testRun.SetAttribute("EndTime", testcaseinfo.EndTime.ToString(_timeFormat));
                Save(testRun, document, testcaseinfo);
                String hostName = Dns.GetHostName();

                String name = hostName + "_SplunkTestLog.splog";
                //String name = Guid.NewGuid().ToString() + "_" + "SplunkTestLog.splog";
                String fileName = logDirectory + "\\" + name;
                if (File.Exists(fileName))
                {
                    File.Delete(fileName);
                }

                document.Save(fileName);
            }
            catch (Exception exe)
            {
                return false;
            }
            return true;
        }
コード例 #8
0
ファイル: PairwiseStrategy.cs プロジェクト: yunmiha/TizenFX
            /// <summary>
            /// Creates a set of test cases for specified dimensions.
            /// </summary>
            /// <param name="dimensions">
            /// An array which contains information about dimensions. Each element of
            /// this array represents a number of features in the specific dimension.
            /// </param>
            /// <returns>
            /// A set of test cases.
            /// </returns>
            public IEnumerable GetTestCases(int[] dimensions)
            {
                _prng       = new FleaRand(15485863);
                _dimensions = dimensions;

                CreateAllTuples();

                List <TestCaseInfo> testCases = new List <TestCaseInfo>();

                while (true)
                {
                    FeatureTuple tuple = GetNextTuple();

                    if (tuple == null)
                    {
                        break;
                    }

                    TestCaseInfo testCase = CreateTestCase(tuple);

                    RemoveTuplesCoveredByTest(testCase);

                    testCases.Add(testCase);
                }

#if DEBUG
                SelfTest(testCases);
#endif

                return(testCases);
            }
コード例 #9
0
ファイル: PairwiseStrategy.cs プロジェクト: yunmiha/TizenFX
            private int MaximizeCoverage(TestCaseInfo testCase, FeatureTuple tuple)
            {
                // It starts with one because we always have one tuple which is covered by the test.
                int totalCoverage = 1;

                int[] mutableDimensions = GetMutableDimensions(tuple);

                while (true)
                {
                    bool progress = false;

                    ScrambleDimensions(mutableDimensions);

                    for (int i = 0; i < mutableDimensions.Length; i++)
                    {
                        int d = mutableDimensions[i];

                        int bestCoverage = CountTuplesCoveredByTest(testCase, d, testCase.Features[d]);

                        int newCoverage = MaximizeCoverageForDimension(testCase, d, bestCoverage);

                        totalCoverage += newCoverage;

                        if (newCoverage > bestCoverage)
                        {
                            progress = true;
                        }
                    }

                    if (!progress)
                    {
                        return(totalCoverage);
                    }
                }
            }
コード例 #10
0
ファイル: PairwiseStrategy.cs プロジェクト: yunmiha/TizenFX
            private int MaximizeCoverageForDimension(TestCaseInfo testCase, int dimension, int bestCoverage)
            {
                List <int> bestFeatures = new List <int>(_dimensions[dimension]);

                for (int f = 0; f < _dimensions[dimension]; f++)
                {
                    testCase.Features[dimension] = f;

                    int coverage = CountTuplesCoveredByTest(testCase, dimension, f);

                    if (coverage >= bestCoverage)
                    {
                        if (coverage > bestCoverage)
                        {
                            bestCoverage = coverage;
                            bestFeatures.Clear();
                        }

                        bestFeatures.Add(f);
                    }
                }

                testCase.Features[dimension] = bestFeatures[GetNextRandomNumber() % bestFeatures.Count];

                return(bestCoverage);
            }
コード例 #11
0
        private void dataGridViewTestCases_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            TestCaseInfo toLoad = CurrentRegexInfo.TestCaseInfos[dataGridViewTestCases.SelectedIndex];

            SetCurrentTestCaseInfo(toLoad, true);
            e.Handled = true;
        }
コード例 #12
0
        public Task <bool> DeleteAsync(Guid id)
        {
            int    count  = this.methodInfos.RemoveAll(o => o.Id.Equals(id));
            string output = TestCaseInfo.SerializeList(this.methodInfos);

            File.WriteAllText(defaultReposFile, output, this.configurationManager.GetEncoding());
            return(Task.FromResult(count == 1));
        }
コード例 #13
0
        public Task <bool> DeleteRange(IEnumerable <TestCaseInfo> items)
        {
            int    count  = this.methodInfos.RemoveAll(o => items.Contains(o));
            string output = TestCaseInfo.SerializeList(this.methodInfos);

            File.WriteAllText(defaultReposFile, output, this.configurationManager.GetEncoding());
            return(Task.FromResult(count == 1));
        }
コード例 #14
0
        private async void SetTestMethodAsync(TestCaseInfo testMethodInfo)
        {
            if (testMethodInfo != null)
            {
                TestResultInfo info = await this.testResultsRepository.GetTestResultAsync(testMethodInfo.DisplayName);

                this.CurrentTestMethodResult = info;
            }
        }
コード例 #15
0
        public void LoadTestCaseInfo(TestCaseInfo testCaseInfo, int num)
        {
            this.testCaseInfo = testCaseInfo;
            TextMeshProUGUI Rownum = UtilityHelper.FindChild <TextMeshProUGUI>(this.transform, "Rownum");

            Rownum.text = num.ToString();
            TextMeshProUGUI Description = UtilityHelper.FindChild <TextMeshProUGUI>(this.transform, "Description");

            Description.text = testCaseInfo.description;
        }
コード例 #16
0
        public async Task Blank_search_text_returns_an_empty_array(string searchText, string description)
        {
            var testCase = new TestCaseInfo
                           (
                testCaseDetails: $"{description} search text returns an empty array",
                searchText: searchText,
                people: new PersonInfo[] { }
                           );

            await ExecuteSearchTest(testCase);
        }
コード例 #17
0
 public void Save(XmlElement root, XmlDocument doc, TestCaseInfo testcaseinfo)
 {
     XmlElement testElement = doc.CreateElement("TestCase");
     testElement.SetAttribute("Name", testcaseinfo.TestName);
     testElement.SetAttribute("StartTime", testcaseinfo.StartTime.ToString(_timeFormat)); ;
     testElement.SetAttribute("EndTime", testcaseinfo.EndTime.ToString(_timeFormat));
     int count = 1;
     //TestIteration iteration = testCase.GetIterations()[count - 1];
     root.AppendChild(testElement);
     Save(testElement, doc, testcaseinfo, count);
 }
コード例 #18
0
        private string ConvertToTestMethodInfo(TestCaseInfo methodInfo)
        {
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.AppendLine($"类名:{methodInfo.TestClassName};");
            stringBuilder.AppendLine($"测试用例名称:{methodInfo.DisplayName};");
            stringBuilder.AppendLine($"分类:{methodInfo.Categories};");
            stringBuilder.AppendLine($"属性:{methodInfo.TestMethodProperties};");
            stringBuilder.AppendLine(methodInfo.Description.Replace(" ", ""));
            return(stringBuilder.ToString());
        }
コード例 #19
0
        private static bool IsTupleCovered(this TestCaseInfo testCaseInfo, FeatureTuple tuple)
        {
            for (int i = 0; i < tuple.Length; i++)
            {
                if (testCaseInfo.Features[tuple[i].Dimension] != tuple[i].Feature)
                {
                    return(false);
                }
            }

            return(true);
        }
コード例 #20
0
        public static Results RunEqualityTestCase(Results testResult)
        {
            Results newResult = new Results();

            newResult.TestDate            = DateTime.Now.ToShortDateString();
            newResult.TestCaseName        = TestCaseInfo.EqualityTestName(testResult.TargetTableName);
            newResult.SourceTableName     = testResult.SourceTableName;
            newResult.TargetTableName     = testResult.TargetTableName;
            newResult.TestCaseDescription = TestCaseInfo.EqualityTestDescription();
            newResult.Result = "Pass";

            return(newResult);
        }
コード例 #21
0
        private void CheckBox_CheckContrast(object sender, RoutedEventArgs e)
        {
            this.testMethodListViewModel.TestMethodsSelectChangedCommand.Execute(null);
            foreach (object o in this.TestMethodList.Items)
            {
                TestCaseInfo testCase = o as TestCaseInfo;
                if (testCase.Status != TestOutcome.NotFound && testCase.Status != TestOutcome.Skipped)
                {
                    testCase.Selected = !testCase.Selected;
                }
            }

            this.TestMethodCollectionView.View.Refresh();
        }
コード例 #22
0
        public async Task Full_match_beats_partial_match()
        {
            var testCase = new TestCaseInfo
                           (
                testCaseDetails: "Full match beats partial match",
                searchText: "First Middle Last",
                people: new PersonInfo[]
            {
                new PersonInfo("First", "Middle", "Last", 1),
                new PersonInfo("First", "Middleton", "Last", 2)
            }
                           );

            await ExecuteSearchTest(testCase);
        }
コード例 #23
0
        public async Task Correct_last_name_beats_correct_middle_name()
        {
            var testCase = new TestCaseInfo
                           (
                testCaseDetails: "Correct last name beats correct middle name",
                searchText: "First Middle Last",
                people: new PersonInfo[]
            {
                new PersonInfo("First", "Jade", "Last", 1),
                new PersonInfo("First", "Middle", "Jefferson", 2)
            }
                           );

            await ExecuteSearchTest(testCase);
        }
コード例 #24
0
ファイル: PairwiseStrategy.cs プロジェクト: yunmiha/TizenFX
            private int CountTuplesCoveredByTest(TestCaseInfo testCase, int dimension, int feature)
            {
                int result = 0;

                List <FeatureTuple> tuples = _uncoveredTuples[dimension][feature];

                for (int i = 0; i < tuples.Count; i++)
                {
                    if (testCase.IsTupleCovered(tuples[i]))
                    {
                        result++;
                    }
                }

                return(result);
            }
コード例 #25
0
ファイル: PairwiseStrategy.cs プロジェクト: yunmiha/TizenFX
            private TestCaseInfo CreateRandomTestCase(FeatureTuple tuple)
            {
                TestCaseInfo result = new TestCaseInfo(_dimensions.Length);

                for (int d = 0; d < _dimensions.Length; d++)
                {
                    result.Features[d] = GetNextRandomNumber() % _dimensions[d];
                }

                for (int i = 0; i < tuple.Length; i++)
                {
                    result.Features[tuple[i].Dimension] = tuple[i].Feature;
                }

                return(result);
            }
コード例 #26
0
 private void SetCurrentTestCaseInfo(TestCaseInfo current, bool switchTab)
 {
     this.CurrentTestCaseInfo = current;
     if (current != null)
     {
         this.textBoxItemToMatch.Text = current.TextToMatch;
     }
     else
     {
         this.textBoxItemToMatch.Text = "";
     }
     if (switchTab)
     {
         tabControlRegex.SelectedIndex = 0;
     }
 }
コード例 #27
0
 private void buttonRenameTestCase_Click(object sender, RoutedEventArgs e)
 {
     if (dataGridViewTestCases.SelectedItems.Count == 1)
     {
         TestCaseInfo testCaseInfo = (TestCaseInfo)dataGridViewTestCases.SelectedItems[0];
         SaveWindow   renameWindow = new SaveWindow("Rename Test Case")
         {
             Name = testCaseInfo.Name
         };
         renameWindow.ShowDialog();
         if (renameWindow.DialogResult.GetValueOrDefault())
         {
             testCaseInfo.Name = renameWindow.Name;
             model.SaveRegexs(CurrentRegexs);
             RefreshLoadedRegexsView();
         }
     }
 }
コード例 #28
0
ファイル: PairwiseStrategy.cs プロジェクト: yunmiha/TizenFX
            private void RemoveTuplesCoveredByTest(TestCaseInfo testCase)
            {
                for (int d = 0; d < _uncoveredTuples.Length; d++)
                {
                    for (int f = 0; f < _uncoveredTuples[d].Length; f++)
                    {
                        List <FeatureTuple> tuples = _uncoveredTuples[d][f];

                        for (int i = tuples.Count - 1; i >= 0; i--)
                        {
                            if (testCase.IsTupleCovered(tuples[i]))
                            {
                                tuples.RemoveAt(i);
                            }
                        }
                    }
                }
            }
コード例 #29
0
        public async Task Records_without_2_matches_are_ignored()
        {
            var testCase = new TestCaseInfo
                           (
                testCaseDetails: "Records without at 2 matches are ignored",
                searchText: "First Middle Last",
                people: new PersonInfo[]
            {
                new PersonInfo("First", "Middleton", "Last", 1),
                new PersonInfo("Firstish", "Middleton", "jasfdlkjaf", 2),
                new PersonInfo("First", "asdf", "asdfafs", null),
                new PersonInfo("asfasf", "Middle", "asdfafs", null),
                new PersonInfo("asdf", "asdf", "Last", null),
            }
                           );

            await ExecuteSearchTest(testCase);
        }
コード例 #30
0
        private void buttonSaveTestAs_Click(object sender, RoutedEventArgs e)
        {
            SaveWindow saveWindow = new SaveWindow("Save Test");

            saveWindow.ShowDialog();
            if (saveWindow.DialogResult.GetValueOrDefault())
            {
                TestCaseInfo testCaseInfo = new TestCaseInfo
                {
                    Id          = Guid.NewGuid(),
                    Name        = saveWindow.Name,
                    TextToMatch = textBoxItemToMatch.Text
                };
                CurrentRegexInfo.TestCaseInfos.Add(testCaseInfo);
                CurrentTestCaseInfo = testCaseInfo;
                model.SaveRegexs(CurrentRegexs);
                RefreshLoadedRegexsView();
            }
        }
コード例 #31
0
        private TestSuiteInfo GetTestSuiteInfoFromTestSuiteFile(string filePath)
        {
            var       testSuite = new TestSuiteInfo();
            XDocument xdoc;

            try
            {
                xdoc = XDocument.Load(filePath);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }

            testSuite.Name   = xdoc.XPathSelectElement("/TestSuite/Name")?.Value;
            testSuite.Target = xdoc.XPathSelectElement("/TestSuite/Target")?.Value;

            foreach (var testcaseElement in xdoc.XPathSelectElements("/TestSuite/TestCases/TestCase"))
            {
                var testCase = new TestCaseInfo {
                    Id = testcaseElement.Attribute("ID")?.Value
                };

                foreach (var assertionElement in testcaseElement.XPathSelectElements("Assertions/Assertion"))
                {
                    var assertion = new AssertionInfo
                    {
                        Id          = assertionElement.Attribute("ID")?.Value,
                        InputValues = assertionElement.XPathSelectElements("InputValues/InputValue")
                                      .Select(v => Convert.ToDouble(v.Value)).ToList(),
                        ExpectedOutput = assertionElement.XPathSelectElement("ExpectedOutput")?.Value,
                        ActualOutput   = assertionElement.XPathSelectElement("ActualOutput")?.Value,
                        Result         = assertionElement.XPathSelectElement("Result")?.Value
                    };
                    testCase.Assertions.Add(assertion);
                }

                testSuite.TestCases.Add(testCase);
            }

            return(testSuite);
        }
コード例 #32
0
ファイル: PairwiseStrategy.cs プロジェクト: yunmiha/TizenFX
            private TestCaseInfo CreateTestCase(FeatureTuple tuple)
            {
                TestCaseInfo bestTestCase = null;
                int          bestCoverage = -1;

                for (int i = 0; i < 7; i++)
                {
                    TestCaseInfo testCase = CreateRandomTestCase(tuple);

                    int coverage = MaximizeCoverage(testCase, tuple);

                    if (coverage > bestCoverage)
                    {
                        bestTestCase = testCase;
                        bestCoverage = coverage;
                    }
                }

                return(bestTestCase);
            }
コード例 #33
0
ファイル: XMLTestRunReport.cs プロジェクト: vinukj/CUITLogger
 public void Save(XmlElement root, XmlDocument doc, TestCaseInfo testCaseinfo, int count)
 {
     XmlElement testElement = doc.CreateElement("Iteration");
     testElement.SetAttribute("Priority", testCaseinfo.Priority.ToString());
     testElement.SetAttribute("Owner", testCaseinfo.Owner);
     testElement.SetAttribute("TestId", testCaseinfo.TestId);
     testElement.SetAttribute("Category", testCaseinfo.Category);
     testElement.SetAttribute("Module", testCaseinfo.ModuleName);
     testElement.SetAttribute("Result", testCaseinfo.TestOutCome);
     // TestEnvironment en = TestSession.Config.GetWebActiveEnvironment();
     // testElement.SetAttribute("Project", TestSession.Config.GetAppSettings(ConfigKeys.Project));
     //testElement.SetAttribute("Environment", en.Name);
     if (count > 1)
     {
         testElement.SetAttribute("IterationName", testCaseinfo.TestName + "_" + count);
     }
     else
     {
         testElement.SetAttribute("IterationName", testCaseinfo.TestName);
     }
     //String buildNo = "";
     //BuildInfoModel info = en.BuildInfoModel;
     //if (info != null)
     //{
     //    buildNo = info.Version;
     //}
     //testElement.SetAttribute("BuildNo", buildNo);
     string timeFormat = "yyyy-MM-dd";
     string runDate = testCaseinfo.StartTime.ToString(timeFormat);
     testElement.SetAttribute("TestRunDate", runDate);
     timeFormat = "HH:mm:ss";
     string runTime = testCaseinfo.StartTime.ToString(timeFormat);
     testElement.SetAttribute("TestRunTime", runTime);
      // Convert the Text file to XML file
     List<string> textfile = File.ReadAllLines("C:\\Temp\\Result.txt").ToList();
   
     //String text = iteration.GetMessage();
     //testElement.SetAttribute("Message", text == null ? "" : text);
     root.AppendChild(testElement);
     this.Steps(root, doc, textfile);
 }
コード例 #34
0
        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;
        }
コード例 #35
0
            private int CountTuplesCoveredByTest(TestCaseInfo testCase, int dimension, int feature)
            {
                int result = 0;

                List<FeatureTuple> tuples = this.uncoveredTuples[dimension][feature];

                for (int i = 0; i < tuples.Count; i++)
                {
                    if (testCase.IsTupleCovered(tuples[i]))
                    {
                        result++;
                    }
                }

                return result;
            }
コード例 #36
0
            private int MaximizeCoverageForDimension(TestCaseInfo testCase, int dimension, int bestCoverage)
            {
                List<int> bestFeatures = new List<int>(this.dimensions[dimension]);

                for (int f = 0; f < this.dimensions[dimension]; f++)
                {
                    testCase.Features[dimension] = f;

                    int coverage = this.CountTuplesCoveredByTest(testCase, dimension, f);

                    if (coverage >= bestCoverage)
                    {
                        if (coverage > bestCoverage)
                        {
                            bestCoverage = coverage;
                            bestFeatures.Clear();
                        }

                        bestFeatures.Add(f);
                    }
                }

                testCase.Features[dimension] = bestFeatures[this.GetNextRandomNumber() % bestFeatures.Count];

                return bestCoverage;
            }
コード例 #37
0
            private int MaximizeCoverage(TestCaseInfo testCase, FeatureTuple tuple)
            {
                // It starts with one because we always have one tuple which is covered by the test.
                int totalCoverage = 1;
                int[] mutableDimensions = this.GetMutableDimensions(tuple);

                while (true)
                {
                    bool progress = false;

                    this.ScrambleDimensions(mutableDimensions);

                    for (int i = 0; i < mutableDimensions.Length; i++)
                    {
                        int d = mutableDimensions[i];

                        int bestCoverage = this.CountTuplesCoveredByTest(testCase, d, testCase.Features[d]);

                        int newCoverage = this.MaximizeCoverageForDimension(testCase, d, bestCoverage);

                        totalCoverage += newCoverage;

                        if (newCoverage > bestCoverage)
                        {
                            progress = true;
                        }
                    }

                    if (!progress)
                    {
                        return totalCoverage;
                    }
                }
            }
コード例 #38
0
            private TestCaseInfo CreateRandomTestCase(FeatureTuple tuple)
            {
                TestCaseInfo result = new TestCaseInfo(this.dimensions.Length);

                for (int d = 0; d < this.dimensions.Length; d++)
                {
                    result.Features[d] = this.GetNextRandomNumber() % this.dimensions[d];
                }

                for (int i = 0; i < tuple.Length; i++)
                {
                    result.Features[tuple[i].Dimension] = tuple[i].Feature;
                }

                return result;
            }
コード例 #39
0
            private void RemoveTuplesCoveredByTest(TestCaseInfo testCase)
            {
                for (int d = 0; d < this.uncoveredTuples.Length; d++)
                {
                    for (int f = 0; f < this.uncoveredTuples[d].Length; f++)
                    {
                        List<FeatureTuple> tuples = this.uncoveredTuples[d][f];

                        for (int i = tuples.Count - 1; i >= 0; i--)
                        {
                            if (testCase.IsTupleCovered(tuples[i]))
                            {
                                tuples.RemoveAt(i);
                            }
                        }
                    }
                }
            }