Esempio n. 1
0
 // Convert the test structure into a runner based on current selection and runner type
 void GenerateTestRunner(TestStructure.Structure inputStructure)
 {
     runner = new Runner();                                                                        // Create new Runner instance
     for (int su = 0; su < inputStructure.suites.Count; su++)                                      // Iterate suites
     {
         if (inputStructure.suites[su].selectionState != 0 || runnerType != RunnerType.Automation) // If selected or automation
         {
             string suiteName = inputStructure.suites[su].suiteName;
             for (int ty = 0; ty < inputStructure.suites[su].types.Count; ty++)                                      // Iterate types
             {
                 if (inputStructure.suites[su].types[ty].selectionState != 0 || runnerType != RunnerType.Automation) // If selected or automation
                 {
                     string typeName  = inputStructure.suites[su].types[ty].typeName;
                     int    typeIndex = inputStructure.suites[su].types[ty].typeIndex;
                     for (int gr = 0; gr < inputStructure.suites[su].types[ty].groups.Count; gr++)                                      // Iterate scenes
                     {
                         if (inputStructure.suites[su].types[ty].groups[gr].selectionState != 0 || runnerType != RunnerType.Automation) // If selected or automation
                         {
                             string groupName = inputStructure.suites[su].types[ty].groups[gr].groupName;
                             for (int te = 0; te < inputStructure.suites[su].types[ty].groups[gr].tests.Count; te++)                                      // Iterate tests
                             {
                                 if (inputStructure.suites[su].types[ty].groups[gr].tests[te].selectionState != 0 || runnerType != RunnerType.Automation) // If selected or automation
                                 {
                                     string testName  = inputStructure.suites[su].types[ty].groups[gr].tests[te].testName;
                                     string scenePath = inputStructure.suites[su].types[ty].groups[gr].tests[te].scenePath;
                                     if (!inputStructure.suites[su].types[ty].groups[gr].tests[te].baseline || runnerType != RunnerType.Resolve)            // If baseline resolution mode return all with no baselines
                                     {
                                         TestEntry newTest = new TestEntry(suiteName, groupName, scenePath, typeName, testName, typeIndex, su, gr, ty, te); // Create new TestEntry instance
                                         runner.tests.Add(newTest);                                                                                         // Add to runner
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     Console.Instance.Write(DebugLevel.Logic, MessageLevel.Log, "Generated test runner"); // Write to console
     if (runnerType != RunnerType.Resolve)                                                // If in Resolve mode we start tests manually
     {
         StartTests();                                                                    // Start tests
     }
 }
Esempio n. 2
0
        // Generate a list of results based on selected filters
        public IEnumerator GenerateFilteredResultList()
        {
            Console.Instance.Write(DebugLevel.Full, MessageLevel.Log, "Filtering results");                                       // Write to console
            filteredResultsEntries.Clear();                                                                                       // Clear current
            TestStructure.Structure structure = TestStructure.Instance.GetStructure();                                            // Get structure
            for (int su = 0; su < structure.suites.Count; su++)                                                                   // Iterate suites
            {
                if (su == suitesDropdown.value - 1 || suitesDropdown.value == 0)                                                  // If passes suites filter
                {
                    string suiteName = structure.suites[su].suiteName;                                                            // Get suite name
                    for (int ty = 0; ty < structure.suites[su].types.Count; ty++)                                                 // Iterate types
                    {
                        int typeIndex = structure.suites[su].types[ty].typeIndex;                                                 // Get type index
                        if (typeIndex == typesDropdown.value - 1 || typesDropdown.value == 0)                                     // If passes types filter
                        {
                            string typeName = structure.suites[su].types[ty].typeName;                                            // Get type name
                            for (int gr = 0; gr < structure.suites[su].types[ty].groups.Count; gr++)                              // Iterate groups
                            {
                                string groupName = structure.suites[su].types[ty].groups[gr].groupName;                           // Get group name
                                for (int te = 0; te < structure.suites[su].types[ty].groups[gr].tests.Count; te++)                // Iterate tests
                                {
                                    string            testName  = structure.suites[su].types[ty].groups[gr].tests[te].testName;   // Get test name
                                    string            scenePath = structure.suites[su].types[ty].groups[gr].tests[te].scenePath;  // Get scene path
                                    ResultsDataCommon common    = BuildResultsDataCommon(groupName, testName);                    // Build results data common to retrieve results
                                    ResultsIOData     data      = ResultsIO.Instance.RetrieveResult(suiteName, typeName, common); // Retrieve results data
                                    if (resultsDropdown.value != 0)                                                               // If filtering based on results
                                    {
                                        int passFail = 2;                                                                         // Set default state (no results)
                                        if (data != null)                                                                         // If results data exists
                                        {
                                            passFail = data.resultsRow[0].resultsColumn[21] == "True" ? 0 : 1;                    // Set pass fail state
                                        }
                                        switch (resultsDropdown.value)
                                        {
                                        case 1:     // Pass
                                            if (passFail == 0)
                                            {
                                                filteredResultsEntries.Add(new ResultsEntryData(new TestEntry(suiteName, groupName, scenePath, typeName, testName, typeIndex, su, gr, ty, te), data));     // Add to list
                                            }
                                            break;

                                        case 2:     // Fail
                                            if (passFail == 1)
                                            {
                                                filteredResultsEntries.Add(new ResultsEntryData(new TestEntry(suiteName, groupName, scenePath, typeName, testName, typeIndex, su, gr, ty, te), data));     // Add to list
                                            }
                                            break;

                                        case 3:     // Ran
                                            if (passFail != 2)
                                            {
                                                filteredResultsEntries.Add(new ResultsEntryData(new TestEntry(suiteName, groupName, scenePath, typeName, testName, typeIndex, su, gr, ty, te), data));     // Add to list
                                            }
                                            break;

                                        case 4:     // Not Ran
                                            if (passFail == 2)
                                            {
                                                filteredResultsEntries.Add(new ResultsEntryData(new TestEntry(suiteName, groupName, scenePath, typeName, testName, typeIndex, su, gr, ty, te), data));     // Add to list
                                            }
                                            break;
                                        }
                                    }
                                    else
                                    {
                                        filteredResultsEntries.Add(new ResultsEntryData(new TestEntry(suiteName, groupName, scenePath, typeName, testName, typeIndex, su, gr, ty, te), data)); // Add to list
                                    }
                                    yield return(null);
                                }
                            }
                        }
                    }
                }
            }
        }