Beispiel #1
0
        private static object StepWrapper(MemberInfo member, IWebDriver driver)
        {
            var field    = member as FieldInfo;
            var property = member as PropertyInfo;

            Type targetType = null;

            if (field != null)
            {
                targetType = field.FieldType;
            }

            bool hasPropertySet = false;

            if (property != null)
            {
                hasPropertySet = property.CanWrite;
                targetType     = property.PropertyType;
            }

            if (field == null & (property == null || !hasPropertySet))
            {
                return(null);
            }

            var stepProxy = new StepProxy(targetType, driver);

            return(stepProxy.GetTransparentProxy());
        }
Beispiel #2
0
        public static TestCase ExecuteTestMethod(MethodInfo testMethod, Status suiteStatus, object suiteInstance, int index, object[] paras = null, TestCase testCase = null)
        {
            if (testCase == null)
            {
                testCase = CreateTestCase(testMethod, suiteStatus, index);
            }

            Logger.LogMsg(Severity.INFO, $"Test case: {testMethod.Name} started at: {DateTime.Now}");
            object testReturn = null;

            try
            {
                StepProxy.InitiateTestExecution(testCase.Status);
                testReturn = testMethod.Invoke(suiteInstance, paras);
            }
            catch (Exception ex)
            {
                testCase.SetStatus(Status.Failed);
                Logger.LogMsg(Severity.ERROR, $"Runner exception: {ex.GetLastInnerException().Message}. StackTrace: {ex.GetLastInnerException().StackTrace}");
                testCase.SetError($"Runner exception: {ex.GetLastInnerException().Message}. StackTrace: {ex.GetLastInnerException().StackTrace}");
            }

            testCase.SetValue(testReturn);
            testCase.AddTestSteps(StepProxy.TestSteps);
            StepProxy.CompleteTestExecution();
            if (testCase.Status == Status.Undefined)
            {
                testCase.SetStatus(DetermineTestCaseStatus(testCase));
            }

            testCase.Finish();
            Logger.LogMsg(Severity.INFO, $"Test case: {testCase.Name} => Status is: {testCase.Status}...");
            Logger.LogMsg(Severity.INFO, $"Test case: {testMethod.Name} completed at: {DateTime.Now}...");

            return(testCase);
        }