/// <summary> /// Running test case /// </summary> public void Run() { var setUp = TestHelper.GetFirstMethod(_fixture.Type, attribute => attribute.AttributeType.FullName == TestAttributes.SetUp); var tearDown = TestHelper.GetFirstMethod(_fixture.Type, attribute => attribute.AttributeType.FullName == TestAttributes.TearDown); var obj = _fixture.Instance; Result = new TestResultInfo { Name = Method.Name }; try { Debug.WriteLine(Method.Name + " started."); var ignoreAttribute = Method.GetAttribute(TestAttributes.Ignore); if (ignoreAttribute != null) { Result.Success = TestResult.Ignored; Result.Details = "Ignored due to: " + ignoreAttribute.ConstructorArguments[0].Value; Debug.WriteLine(Method.Name + " ignored."); } else { if (setUp != null) { setUp.Invoke(obj, null); } Invoke(Method, obj); if (tearDown != null) { tearDown.Invoke(obj, null); } Result.Success = TestResult.Success; Debug.WriteLine(Method.Name + " passed."); } } catch (Exception ex) { Result.Success = TestResult.Fail; Result.Details = TestHelper.GetExceptionDetails(ex); Debug.WriteLine(Method.Name + " failed."); } }
/// <summary> /// Running test case /// </summary> public void Run() { var setUp = TestHelper.GetFirstMethod(_fixture.Type, attribute => attribute.AttributeType.FullName == TestAttributes.SetUp); var tearDown = TestHelper.GetFirstMethod(_fixture.Type, attribute => attribute.AttributeType.FullName == TestAttributes.TearDown); var obj = _fixture.Instance; Result = new TestResultInfo { Name = Method.Name }; try { Debug.WriteLine(Method.Name + " started."); var ignoreAttribute = Method.GetAttribute(TestAttributes.Ignore); if (ignoreAttribute != null) { Result.Success = TestResult.Ignored; Result.Details = "Ignored due to: " + ignoreAttribute.ConstructorArguments[0].Value; Debug.WriteLine(Method.Name + " ignored."); } else { if (setUp != null) setUp.Invoke(obj, null); Invoke(Method, obj); if (tearDown != null) tearDown.Invoke(obj, null); Result.Success = TestResult.Success; Debug.WriteLine(Method.Name + " passed."); } } catch (Exception ex) { Result.Success = TestResult.Fail; Result.Details = TestHelper.GetExceptionDetails(ex); Debug.WriteLine(Method.Name + " failed."); } }