Beispiel #1
0
        public static bool AddTestScenario(AddScenarioCmdletBase cmdlet)
        {
            bool result = false;
            result =
                TMX.TestData.AddTestScenario(cmdlet.InputObject,
                                             cmdlet.Name,
                                             cmdlet.Id,
                                             cmdlet.Description,
                                             cmdlet.TestSuiteName,
                                             cmdlet.TestSuiteId);

            return result;
        }
Beispiel #2
0
        /// <summary>
        /// This example demonstrates how to generate test results and
        /// store them to a database and to an XML file.
        /// </summary>
        /// <param name="args"></param>
        public static void Main(string[] args)
        {
            // these are our collections: test suites plus test results
            System.Collections.ArrayList stories = new System.Collections.ArrayList();
            System.Collections.ArrayList results = new System.Collections.ArrayList();

            Console.WriteLine("generating test data");
            // generating test data
            stories.Add(new TestStory("01", "story01"));
            results.Add(new TestResult("001", "test result 01", "bla-bla-bla", "01", "PASSED"));
            results.Add(new TestResult("002", "test result 02", "bla-bla-bla", "01", "PASSED"));
            results.Add(new TestResult("003", "test result 03", "bla-bla-bla", "01", "PASSED"));
            stories.Add(new TestStory("02", "story01"));
            results.Add(new TestResult("123", "test result 123", "bla-bla-bla", "02", "PASSED"));
            results.Add(new TestResult("456", "test result 456", "bla-bla-bla", "02", "PASSED"));
            results.Add(new TestResult("789", "test result 789", "bla-bla-bla", "02", "FAILED"));
            stories.Add(new TestStory("03", "story01"));
            results.Add(new TestResult("abc", "test result abc", "bla-bla-bla", "03", "FAILED"));
            results.Add(new TestResult("def", "test result def", "bla-bla-bla", "03", "FAILED"));
            results.Add(new TestResult("xyz", "test result xyz", "bla-bla-bla", "03", "PASSED"));
            Console.WriteLine("test data have been generated");

            Console.WriteLine("writing test data to library");

            // generating test scenarios for previously generated suites and test results
            foreach (TestStory story in stories) {

                // creating a new test suite == user story
                TMX.TMXHelper.NewTestSuite(
                    story.Name,
                    story.Id,
                    "description");

                foreach (TestResult result in results) {
                    if (result.StoryId == story.Id) {

                        AddScenarioCmdletBase cmdlet =
                            new AddScenarioCmdletBase();
                            cmdlet.Id = result.Id;
                            cmdlet.Name = result.Name;
                            cmdlet.Description = "description";

                        // adding a new test scenario to the test suite
                        // test scenario == name and id of th corresponding test result
                        TMX.TMXHelper.AddTestScenario(cmdlet);

                        // create a test result with the same name and id as the test scenario has
                        TMX.TMXHelper.CloseTestResult(
                            result.Name,
                            result.Id,
                            true, // Passed
                            false, // not a KnownIssue
                            null,
                            null,
                            "description",
                            // 20130322
                            //false);
                            false,
                            true);

                    }
                }
            }
            Console.WriteLine("test data are ready");

            // creating a database
            Console.WriteLine("creating DB");
            TMX.SQLiteHelper.CreateDatabase(
                new TMX.DatabaseFileCmdletBase(),
                @"c:\1\1.db3",
                false,
                false,
                true);
            Console.WriteLine("DB created");

            // export test results to the DB
            Console.WriteLine("exporting test data to the DB");
            TMX.SQLiteHelper.BackupTestResults(
                //new PSCmdletBase(),
                new TMX.CommonCmdletBase(),
                TMX.TestData.CurrentResultsDB.Name);
                //TMX.TestData.CurrentResultsDB.Connection);

            // closing the database
            Console.WriteLine("closing the DB");
            TMX.SQLiteHelper.CloseDatabase(
                //new PSCmdletBase(),
                new TMX.CommonCmdletBase(),
                TMX.TestData.CurrentTestResult.Name);

            // export data to an XML sheet
            Console.WriteLine("export to XML");
            TMX.TMXHelper.ExportResultsToXML(
                (new ImportExportCmdletBase()),
                @"C:\1\export_file.xml");

            Console.Write("Press any key to continue . . . ");
            Console.ReadKey(true);
        }