Exemple #1
0
        private TestResultInfo RunTest(MethodInfo test)
        {
            var attr     = test.GetAttribute <TestAttribute>();
            var testInfo = new TestResultInfo {
                Name = attr.Name, Description = attr.Description
            };

            if (test.ContainsAttribute <IgnoreTestAttribute>())
            {
                testInfo.Result = TestResult.Ignored;
                return(testInfo);
            }

            try
            {
                test.Invoke(Instance, null);
                testInfo.Result = TestResult.Success;
                return(testInfo);
            }
            catch (Exception ex)
            {
                // The main exception will always be a TargetInvocationException because we invoke via reflection
                var inner = ex.InnerException;
                var trace = new StackTrace(inner, true);

                testInfo.Exception = inner;
                testInfo.Stack     = trace;
                testInfo.Result    = TestResult.Failure;
                return(testInfo);
            }
        }
Exemple #2
0
        private TestResultInfo RunTest(MethodInfo test)
        {
            var attr = test.GetAttribute<TestAttribute>();
            var testInfo = new TestResultInfo { Name = attr.Name, Description = attr.Description };

            if (test.ContainsAttribute<IgnoreTestAttribute>())
            {
                testInfo.Result = TestResult.Ignored;
                return testInfo;
            }

            try
            {
                test.Invoke(Instance, null);
                testInfo.Result = TestResult.Success;
                return testInfo;
            }
            catch(Exception ex)
            {
                // The main exception will always be a TargetInvocationException because we invoke via reflection
                var inner = ex.InnerException;
                var trace = new StackTrace(inner, true);

                testInfo.Exception = inner;
                testInfo.Stack = trace;
                testInfo.Result = TestResult.Failure;
                return testInfo;
            }
        }