コード例 #1
0
        public ExpectedExceptionProcessor(TestMethod testMethod, object source)
        {
            this.testMethod = testMethod;

            this.expectedExceptionType = GetExceptionType(source);
            this.expectedExceptionName = GetExceptionName(source);
            this.expectedMessage = GetExpectedMessage(source);
            this.matchType = GetMatchType(source);
            this.userMessage = GetUserMessage(source);

            string handlerName = GetHandler(source);
            if (handlerName == null)
                this.exceptionHandler = GetDefaultExceptionHandler(testMethod.FixtureType);
            else
            {
                MethodInfo handler = GetExceptionHandler(testMethod.FixtureType, handlerName);
                if (handler != null)
                    this.exceptionHandler = handler;
                else
                {
                    testMethod.RunState = RunState.NotRunnable;
                    testMethod.IgnoreReason = string.Format(
                        "The specified exception handler {0} was not found", handlerName);
                }
            }
        }
コード例 #2
0
ファイル: NSpecTestDecoratorSpec.cs プロジェクト: nspec/NSpec
        public void setup()
        {
            decorateTestSpecification = Substitute.For<DecorateTestSpecification>();
            nspecTestMethodBuilder = new NSpecTestMethodBuilder();
            decorator = new NSpecTestDecorator(decorateTestSpecification, nspecTestMethodBuilder);

            test = NUnitSubstitute.ForTestMethod();
        }
コード例 #3
0
		private UnitTestResult CreateNewTestResult ( TestMethod test, string currentAssemblyPath )
		{
			return new UnitTestResult ()
			{
				Message = "",
				StackTrace = "",
				Duration = 0,
				Test = CreateUnitTestInfo(test),
				AssemblyPath = currentAssemblyPath
			};
		}
コード例 #4
0
		public UnitTestInfo ( TestMethod testMethod )
		{
			if (testMethod == null)
				throw new ArgumentException();

			MethodName = testMethod.MethodName;
			FullMethodName = testMethod.Method.ToString ();
			ClassName = testMethod.FixtureType.Name;
			FullClassName = testMethod.ClassName;
			Namespace = testMethod.Method.ReflectedType.Namespace;
			FullName = testMethod.TestName.FullName;

			ParamName = ExtractMethodCallParametersString (FullName);
		}
コード例 #5
0
ファイル: UnitTestInfo.cs プロジェクト: LostLT/TestTools
 private string GetAssemblyPath(TestMethod testMethod)
 {
     var parent = testMethod as Test;
     var assemblyPath = "";
     while (parent != null)
     {
         parent = parent.Parent;
         if (!(parent is TestAssembly)) continue;
         var path = (parent as TestAssembly).TestName.FullName;
         if (!File.Exists(path)) continue;
         assemblyPath = path;
         break;
     }
     return assemblyPath;
 }
コード例 #6
0
ファイル: NSpecTestMethodBuilder.cs プロジェクト: nspec/NSpec
 public virtual NSpecTestMethod Build(TestMethod test)
 {
     return new NSpecTestMethod(test.Method)
                {
                    BuilderException = test.BuilderException,
                    Categories = test.Categories,
                    Description = test.Description,
                    ExceptionProcessor = test.ExceptionProcessor,
                    Fixture = test.Fixture,
                    IgnoreReason = test.IgnoreReason,
                    Parent = test.Parent,
                    Properties = test.Properties,
                    RunState = test.RunState
                };
 }
コード例 #7
0
        public void setup()
        {
            builder = new NSpecTestMethodBuilder();

            test = NUnitSubstitute.ForTestMethod();
            test.BuilderException = new Exception();
            test.Categories = new ArrayList();
            test.Description = "description";
            test.ExceptionProcessor = Substitute.For<ExpectedExceptionProcessor>(test);
            test.Fixture = this;
            test.IgnoreReason = "ignoreReason";
            test.Parent = NUnitSubstitute.ForTest();
            test.Properties = new Hashtable();
            test.RunState = RunState.Runnable;
        }
コード例 #8
0
		public TestDecorator( TestMethod test )
			//: base( (TestName)test.TestName.Clone() )
            : base( test.Method )
		{
			this.test = test;
			this.RunState = test.RunState;
			this.IgnoreReason = test.IgnoreReason;
            this.Description = test.Description;
            this.Categories = new System.Collections.ArrayList( test.Categories );
            if ( test.Properties != null )
            {
                this.Properties = new ListDictionary();
                foreach (DictionaryEntry entry in test.Properties)
                    this.Properties.Add(entry.Key, entry.Value);
            }
        }
コード例 #9
0
ファイル: UnitTestInfo.cs プロジェクト: 675492062/behaviac
        public UnitTestInfo(TestMethod testMethod) {
            if (testMethod == null)
            { throw new ArgumentException(); }

            MethodName = testMethod.MethodName;
            FullMethodName = testMethod.Method.ToString();
            ClassName = testMethod.FixtureType.Name;
            FullClassName = testMethod.ClassName;
            Namespace = testMethod.Method.ReflectedType.Namespace;
            FullName = testMethod.TestName.FullName;
            ParamName = ExtractMethodCallParametersString(FullName);
            Id = testMethod.TestName.TestID.ToString();

            Categories = testMethod.Categories.Cast<string>().ToArray();

            AssemblyPath = GetAssemblyPath(testMethod);
        }
コード例 #10
0
 private string GetAssemblyPath(TestMethod testMethod)
 {
     Test test = testMethod;
     while (test != null)
     {
         test = test.get_Parent();
         if (test is TestAssembly)
         {
             string path = (test as TestAssembly).get_TestName().get_FullName();
             if (File.Exists(path))
             {
                 return path;
             }
         }
     }
     return "";
 }
コード例 #11
0
 public EditorTestInfo(TestMethod testMethod)
 {
     this.methodName = testMethod.get_MethodName();
     this.fullMethodName = testMethod.get_Method().ToString();
     this.className = testMethod.get_FixtureType().Name;
     this.fullClassName = testMethod.get_ClassName();
     this.Namespace = testMethod.get_Method().ReflectedType.Namespace;
     this.fullName = testMethod.get_TestName().get_FullName();
     this.paramName = ExtractMethodCallParametersString(this.fullName);
     this.id = testMethod.get_TestName().get_TestID().GetHashCode().ToString();
     List<string> list = Enumerable.ToList<string>(Enumerable.Cast<string>(testMethod.get_Categories()));
     if (testMethod.get_Parent().get_Categories().Count > 0)
     {
         list.AddRange(Enumerable.Cast<string>(testMethod.get_Parent().get_Categories()));
     }
     if (testMethod.get_Parent() is ParameterizedMethodSuite)
     {
         list.AddRange(Enumerable.Cast<string>(testMethod.get_Parent().get_Parent().get_Categories()));
     }
     this.categories = list.ToArray();
     this.assemblyPath = this.GetAssemblyPath(testMethod);
     this.isIgnored = testMethod.get_RunState() == 4;
 }
コード例 #12
0
ファイル: NUnitFramework.cs プロジェクト: scottwis/eddie
        /// <summary>
        /// Modify a newly constructed test by checking for ExpectedExceptionAttribute
        /// and setting properties on the test accordingly.
        /// </summary>
        /// <param name="attributes">An array of attributes possibly including NUnit attributes
        /// <param name="test">The test to which the attributes apply</param>
        public static void ApplyExpectedExceptionAttribute(MethodInfo method, TestMethod testMethod)
        {
            Attribute attribute = Reflect.GetAttribute(
                method, NUnitFramework.ExpectedExceptionAttribute, false);

            if (attribute != null)
                testMethod.ExceptionProcessor = new ExpectedExceptionProcessor(testMethod, attribute);
        }
コード例 #13
0
ファイル: Direct.cs プロジェクト: RT-Projects/RT.NUnitDirect
 public DirectTestMethod(TestMethod other)
     : base(other.Method)
 {
     foreach (var fld in typeof(TestMethod).GetAllFields())
         fld.SetValue(this, fld.GetValue(other));
     if (Tests != null)
         foreach (Test child in Tests)
             child.Parent = this;
 }
コード例 #14
0
 public TestLineTreeViewItem(TestMethod test, int depth, TreeViewItem parent) : base(test, depth, parent)
 {
 }
コード例 #15
0
        private testcaseType RunTest(TestMethod t)
        {
            TestFilter filter = new NameFilter(t.TestName);
            var result = (t as TestMethod).Run(new TestListener(), filter);

            //result types
            //Ignored, Failure, NotRunnable, Error, Success
            var testCase = new testcaseType
                {
                    name = t.TestName.Name,
                    executed = result.Executed.ToString(),
                    success = result.IsSuccess.ToString(),
                    asserts = result.AssertCount.ToString(CultureInfo.InvariantCulture),
                    time = result.Time.ToString(CultureInfo.InvariantCulture)
                };

            switch (result.ResultState)
            {
                case ResultState.Cancelled:
                    testCase.result = "Cancelled";
                    break;
                case ResultState.Error:
                    var f = new failureType {message = result.Message, stacktrace = result.StackTrace};
                    testCase.Item = f;
                    testCase.result = "Error";
                    break;
                case ResultState.Failure:
                    var fail = new failureType {message = result.Message, stacktrace = result.StackTrace};
                    testCase.Item = fail;
                    testCase.result = "Failure";
                    break;
                case ResultState.Ignored:
                    testCase.result = "Ignored";
                    break;
                case ResultState.Inconclusive:
                    testCase.result = "Inconclusive";
                    break;
                case ResultState.NotRunnable:
                    testCase.result = "NotRunnable";
                    break;
                case ResultState.Skipped:
                    testCase.result = "Skipped";
                    break;
                case ResultState.Success:
                    testCase.result = "Success";
                    break;
            }

            return testCase;
        }
コード例 #16
0
ファイル: TestThread.cs プロジェクト: scottwis/eddie
 public TestMethodThread(TestMethod testMethod)
     : base(testMethod)
 {
     this.testMethod = testMethod;
 }
コード例 #17
0
ファイル: DynamoRevit.cs プロジェクト: kyoisi/Dynamo
 public DynamoRevitTest(TestMethod test)
 {
     _test = test;
     _listener = new RevitTestEventListener(this);
     RunCommand = new DelegateCommand(Run, CanRun);
     _resultType = DynamoRevitTestResultType.Unknown;
     _testName = _test.TestName.Name;
 }
コード例 #18
0
 public ExpectedExceptionProcessor( TestMethod testMethod )
 {
     this.testMethod = testMethod;
 }
コード例 #19
0
ファイル: NUnitFramework.cs プロジェクト: nobled/mono
		// TODO: Handle this with a separate ExceptionProcessor object
		public static void ApplyExpectedExceptionAttribute(MethodInfo method, TestMethod testMethod)
		{
			Attribute attribute = Reflect.GetAttribute(
                method, NUnitFramework.ExpectedExceptionAttribute, false );

			if (attribute != null)
			{
				testMethod.ExceptionExpected = true;

				Type expectedExceptionType = GetExceptionType( attribute );
				string expectedExceptionName = GetExceptionName( attribute );
				if ( expectedExceptionType != null )
					testMethod.ExpectedExceptionType = expectedExceptionType;
				else if ( expectedExceptionName != null )
					testMethod.ExpectedExceptionName = expectedExceptionName;
				
				testMethod.ExpectedMessage = GetExpectedMessage( attribute );
				testMethod.MatchType = GetMatchType( attribute );
				testMethod.UserMessage = GetUserMessage( attribute );

				string handlerName = GetHandler( attribute );
				if ( handlerName == null )
					testMethod.ExceptionHandler = GetDefaultExceptionHandler( testMethod.FixtureType );
				else
				{
					MethodInfo handler = GetExceptionHandler( testMethod.FixtureType, handlerName );
					if ( handler != null )
						testMethod.ExceptionHandler = handler;
					else
					{
						testMethod.RunState = RunState.NotRunnable;
						testMethod.IgnoreReason = string.Format( 
							"The specified exception handler {0} was not found", handlerName );
					}
				}
			}
		}
コード例 #20
0
 /// <summary>
 /// The constructor method for the class. Sets the local member variables with the passed in values
 /// </summary>
 /// <param name="testMethod">The NUnit Test Method</param>
 /// <param name="testCaseId">The ID of the matching SpiraTeam test case</param>
 public ExtendedNUnitTestCase(TestMethod testMethod, int testCaseId)
     : base(testMethod.Method)
 {
     this.testMethod = testMethod;
     this.testCaseId = testCaseId;
 }
コード例 #21
0
 public ExpectedExceptionProcessor(TestMethod testMethod)
 {
     this.testMethod = testMethod;
 }
コード例 #22
0
 public void TestStarted(TestMethod testCase)
 {
     currentTestName = testCase.TestName.FullName;
 }
コード例 #23
0
 public void SetTestMethod(TestMethod testMethod)
 {
     this.m_Test.testMethod = testMethod;
 }
コード例 #24
0
		private UnitTestInfo CreateUnitTestInfo (TestMethod test)
		{
			//this shouldn't be initialize by constructor
			//return test.UnitTestInfo ();
			return new UnitTestInfo (test);
		}
コード例 #25
0
 private static bool MarkAsNotRunnable(TestMethod testMethod, string reason)
 {
     testMethod.RunState = RunState.NotRunnable;
     testMethod.IgnoreReason = reason;
     return false;
 }