コード例 #1
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);
        }