Ejemplo n.º 1
0
        public void ExpandTestcases(string fileName)
        {
            string testOutput = Path.Combine(TestSupport.CreatedFilesDirectory, fileName + ".Output.txt");

            string        source = Path.Combine(TestSupport.TestFilesDirectory, fileName);
            TestCasesRoot tcr    = new TestCasesRoot();

            tcr.Load(source);

            var             statistics = tcr.CalculateStatistics();
            ExpandTestCases expand     = new ExpandTestCases();
            var             result     = expand.Expand(tcr);

            StringBuilder sb = new StringBuilder();

            sb.AppendLine("TestCases");
            foreach (TestCase tc in tcr.TestCases)
            {
                DumpTestCase(sb, tc);
                sb.AppendLine();
            }
            sb.AppendLine("expanded TestCases");
            foreach (ITestCase tc in result)
            {
                DumpTestCase(sb, tc);
                sb.AppendLine();
            }
            sb.AppendFormat("calculated {0,5}  expandCount {1,5}", statistics.CoveredTestCases, result.Count);

            File.WriteAllText(testOutput, sb.ToString());
            //ProcessStartInfo info = new ProcessStartInfo(@"C:\Program Files (x86)\Notepad++\notepad++.exe", testOutput);
            //Process.Start(info);
            Assert.That(TestSupport.CompareFile(TestSupport.CreatedFilesDirectory, TestSupport.ReferenceFilesDirectory, Path.GetFileName(testOutput)));
            Assert.That(statistics.CoveredTestCases == result.Count);
        }
Ejemplo n.º 2
0
        public void CalculateCoverage(string fileName, long expectedCombinations, long expectedUniqueTestCases, double minExpectedCoverage, double maxExpectedCoverage)
        {
            string testSettingPath = Path.Combine(TestSupport.CreatedFilesDirectory, "TestSetting.txt");

            string        source = Path.Combine(TestSupport.TestFilesDirectory, fileName);
            TestCasesRoot tcr    = new TestCasesRoot();

            tcr.Load(source);
            Statistics stat = tcr.CalculateStatistics();

            for (int idx = 0; idx < tcr.TestCases.Count; idx++)
            {
                File.AppendAllText(testSettingPath, String.Format("{0}" + Environment.NewLine, tcr.TestCases[idx]));
            }
            File.AppendAllText(testSettingPath, Environment.NewLine + Environment.NewLine);

            ExpandTestCases expand            = new ExpandTestCases();
            var             expandedTestCases = expand.Expand(tcr);

            foreach (TestCase expandedTestCase in expandedTestCases)
            {
                File.AppendAllText(testSettingPath, String.Format("{0}" + Environment.NewLine, expandedTestCase));
            }

            //ProcessStartInfo info = new ProcessStartInfo(@"C:\Program Files (x86)\Notepad++\notepad++.exe", testSettingPath);
            //Process.Start(info);

            Assert.That(stat.Coverage >= minExpectedCoverage);
            Assert.That(stat.Coverage <= maxExpectedCoverage);
            Assert.That(stat.CoveredTestCases == expectedUniqueTestCases);
            Assert.That(stat.PossibleCombinations == expectedCombinations);
        }
Ejemplo n.º 3
0
        public void LoadOldProjectFiles(int idx, string fileName)
        {
            string        loadPath = Path.Combine(TestSupport.TestFilesDirectory, fileName);
            string        savePath = Path.Combine(TestSupport.CreatedFilesDirectory, fileName);
            TestCasesRoot root     = new TestCasesRoot();

            root.Load(loadPath);

            root.Save(savePath);
            // only to view the diffrence
            TestSupport.CompareFile(TestSupport.CreatedFilesDirectory, TestSupport.TestFilesDirectory, Path.GetFileName(savePath));
            Assert.That(TestSupport.CompareFile(TestSupport.CreatedFilesDirectory, TestSupport.ReferenceFilesDirectory, Path.GetFileName(savePath)));
            //ProcessStartInfo info = new ProcessStartInfo(@"C:\Program Files (x86)\Notepad++\notepad++.exe", savePath);
            //Process.Start(info);
        }
Ejemplo n.º 4
0
        public void Save100()
        {
            string        savePath = Path.Combine(TestSupport.CreatedFilesDirectory, "Save.dtc");
            TestCasesRoot root     = TestCasesRoot.CreateSimpleTable();

            root.Save(savePath);

            root.New();

            root.Load(savePath);

            Assert.That(TestSupport.CompareFile(TestSupport.CreatedFilesDirectory, TestSupport.ReferenceFilesDirectory, Path.GetFileName(savePath)));
            //ProcessStartInfo info = new ProcessStartInfo(@"C:\Program Files (x86)\Notepad++\notepad++.exe", savePath);
            //Process.Start(info);
        }
Ejemplo n.º 5
0
        public void SaveTestCaseDescription()
        {
            string        savePath = Path.Combine(TestSupport.CreatedFilesDirectory, "Save.dtc");
            TestCasesRoot root     = TestCasesRoot.CreateSimpleTable();

            root.TestCases[0].Description = "test description";
            Assert.True(root.TestCases[1].Description == "");
            root.Save(savePath);

            root.New();

            root.Load(savePath);

            Assert.True(root.TestCases[0].Description == "test description");
            Assert.True(root.TestCases[1].Description == "");
        }
Ejemplo n.º 6
0
        public void CreateMissingTestCases(int idx, string fileName, int expectedTestCasesCount)
        {
            string testOutput = Path.Combine(TestSupport.CreatedFilesDirectory, fileName + ".Output.txt");

            string        source = Path.Combine(TestSupport.TestFilesDirectory, fileName);
            string        target = Path.Combine(TestSupport.CreatedFilesDirectory, fileName);
            TestCasesRoot tcr    = new TestCasesRoot();

            tcr.Load(source);

            StringBuilder sb = new StringBuilder();

            foreach (TestCase tc in tcr.TestCases)
            {
                DumpTestCase(sb, tc);
                sb.AppendLine();
            }

            tcr.CalculateMissingTestCases();

            sb.AppendLine("After calculation");
            foreach (TestCase tc in tcr.TestCases)
            {
                DumpTestCase(sb, tc);
                sb.AppendLine();
            }
            File.WriteAllText(testOutput, sb.ToString());
            ProcessStartInfo info = new ProcessStartInfo(@"C:\Program Files (x86)\Notepad++\notepad++.exe", testOutput);

            //Process.Start(info);

            tcr.Save(target);

            var statistics = tcr.CalculateStatistics();

            if (tcr.TestCases.Count > 0)
            {
                Assert.IsTrue(statistics.Coverage >= 99.9);
            }
            Assert.IsTrue(tcr.TestCases.Count == expectedTestCasesCount);

            TestUtils.CheckTestCasesAndConditionsAndActions(tcr);
        }