예제 #1
0
        /// <summary>
        /// Gets priority of test.
        /// </summary>
        /// <param name="rockSteadyTestCase"></param>
        /// <returns>Priority</returns>
        private static int GetPriority(ObjectModel.TestCase rockSteadyTestCase)
        {
            int priority = int.MaxValue;

            ObjectModel.Trait priorityTrait = rockSteadyTestCase.Traits?.FirstOrDefault(t => t.Name.Equals("Priority"));
            if (priorityTrait != null && Int32.TryParse(priorityTrait.Value, out int priorityValue))
            {
                priority = priorityValue;
            }

            return(priority);
        }
예제 #2
0
        /// <summary>
        /// Gets owner of test.
        /// </summary>
        /// <param name="rockSteadyTestCase"></param>
        /// <returns>Owner</returns>
        private static string GetOwner(ObjectModel.TestCase rockSteadyTestCase)
        {
            string owner = null;

            ObjectModel.Trait ownerTrait = rockSteadyTestCase.Traits?.FirstOrDefault(t => t.Name.Equals("Owner"));
            if (ownerTrait != null)
            {
                owner = ownerTrait.Value;
            }

            return(owner ?? string.Empty);
        }
예제 #3
0
        /// <summary>
        /// Returns QToolsCommon.TestElement from rockSteady TestCase.
        /// </summary>
        /// <param name="rockSteadyTestResult">
        /// The rockSteady Test Result.
        /// </param>
        /// <returns>
        /// The <see cref="UnitTestElement"/>.
        /// </returns>
        internal static TrxObjectModel.UnitTestElement GetQToolsTestElementFromTestCase(ObjectModel.TestResult rockSteadyTestResult)
        {
            ObjectModel.TestCase rockSteadyTestCase = rockSteadyTestResult.TestCase;

            // Fix for bug# 868033
            // Use TMI Test id when available. This is needed to ensure that test id in trx files is same as specified in
            // .vsmdi files.
            // (This is required for test explorer: It removes all test nodes where test id is not in expected test id when merging
            // trx files from different batches).
            Guid testId = GetTmiTestId(rockSteadyTestCase);

#if NET46
            if (Guid.Empty.Equals(testId))
            {
                testId = rockSteadyTestCase.Id;
            }
#else
            testId = Guid.NewGuid();
#endif

            string testDisplayName = rockSteadyTestCase.DisplayName;

            // If it is an inner test case name
            if (!string.IsNullOrEmpty(rockSteadyTestResult.DisplayName))
            {
                testId          = Guid.NewGuid(); // Changing of guid is done so that VS can load trx otherwise it fails with duplicate id error.
                testDisplayName = rockSteadyTestResult.DisplayName;
            }

            TrxObjectModel.TestMethod testMethod = GetTestMethod(testDisplayName, rockSteadyTestCase);

            // convert the rocksteady tests to TestElement.
            TrxObjectModel.UnitTestElement testElement = new TrxObjectModel.UnitTestElement(testId, testDisplayName, rockSteadyTestCase.ExecutorUri.ToString(), testMethod);
            testElement.ExecutionId = new TrxObjectModel.TestExecId(Guid.NewGuid());
            testElement.AssignCodeBase(rockSteadyTestCase.Source);
            testElement.Storage = rockSteadyTestCase.Source;

            if (rockSteadyTestCase.Traits != null)
            {
                ObjectModel.Trait priorityTrait = rockSteadyTestCase.Traits.FirstOrDefault(t => t.Name.Equals("Priority"));
                if (priorityTrait != null)
                {
                    int priorityValue;
                    if (Int32.TryParse(priorityTrait.Value, out priorityValue))
                    {
                        testElement.Priority = priorityValue;
                    }
                }

                ObjectModel.Trait ownerTrait = rockSteadyTestCase.Traits.FirstOrDefault(t => t.Name.Equals("Owner"));
                if (ownerTrait != null)
                {
                    testElement.Owner = ownerTrait.Value;
                }
            }

            // reading TestCategories from the testcase
            var testCategories = GetCustomPropertyValueFromTestCase(rockSteadyTestCase, "MSTestDiscoverer.TestCategory");
            foreach (string testCategory in testCategories)
            {
                testElement.TestCategories.Add(testCategory);
            }

            return(testElement);
        }