Beispiel #1
0
        public override TestResult[] Execute(ITestMethod testMethod)
        {
            TestResult[]       iterationResults = null;
            DataDrivenTypeEnum dataDrivenType   = DataDrivenTypeEnum.None;

            _testInfo = new TestInfo()
            {
                // testMethod.MethodInfo.DeclaringType.FullName
                Class = new ClassObject()
                {
                    FullName = testMethod.TestClassName, Assembly = testMethod.MethodInfo.Module.Name, Description = _classDisplayName
                },
                Test = new TestObject()
                {
                    FullName = $"{testMethod.TestClassName}.{testMethod.TestMethodName}", Description = GetTestDescription(testMethod.MethodInfo), Categories = GetTestCategories(testMethod.MethodInfo)
                },
                Iteration = 0,
                IsChild   = false,
            };

            if (_rowIndex == 0)
            {
                _testInfo = ReporterManager.Get().AddTest(_testInfo);
                _rowIndex = 0;
                _rows     = GetRows(testMethod.MethodInfo, out dataDrivenType);
            }

            TestInfo childTest = (TestInfo)_testInfo.DeepCopy();

            childTest.Iteration        = ++_rowIndex;
            childTest.IsChild          = true;
            childTest.Test.Description = String.Copy(((DataRowAttribute)_rows[_rowIndex - 1]).DisplayName ?? $"{_testInfo.Test.Description} (Row #{_rowIndex})");

            childTest = ReporterManager.Get().AddTestNode(childTest);

            iterationResults = base.Execute(testMethod);
            results.AddRange(iterationResults);

            _testInfo = ReporterManager.Get().TestEnd(childTest);

            if (_rows.Count == _rowIndex)
            {
                ReporterManager.Get().TestEnd(_testInfo);
            }

            return(iterationResults);
        }