Пример #1
0
        public void InitializeContext(UnityTestExecutionContext context)
        {
            Context = context;

            if (Test is TestAssembly)
            {
                Actions.AddRange(ActionsHelper.GetActionsFromTestAssembly((TestAssembly)Test));
            }
            else if (Test is ParameterizedMethodSuite)
            {
                Actions.AddRange(ActionsHelper.GetActionsFromTestMethodInfo(Test.Method));
            }
            else if (Test.TypeInfo != null)
            {
                Actions.AddRange(ActionsHelper.GetActionsFromTypesAttributes(Test.TypeInfo.Type));
            }
        }
Пример #2
0
        private IEnumerable RunChildren()
        {
            int childCount = Children.Count;

            if (childCount == 0)
            {
                throw new InvalidOperationException("RunChildren called but item has no children");
            }

            _childTestCountdown = new CountdownEvent(childCount);

            foreach (UnityWorkItem child in Children)
            {
                if (CheckForCancellation())
                {
                    yield break;
                }

                var unityTestExecutionContext = new UnityTestExecutionContext(Context);
                child.InitializeContext(unityTestExecutionContext);

                var enumerable = child.Execute().GetEnumerator();

                while (true)
                {
                    if (!enumerable.MoveNext())
                    {
                        break;
                    }
                    ResultedInDomainReload |= child.ResultedInDomainReload;
                    yield return(enumerable.Current);
                }

                _suiteResult.AddResult(child.Result);
                childCount--;
            }

            if (childCount > 0)
            {
                while (childCount-- > 0)
                {
                    CountDownChildTest();
                }
            }
        }
        public UnityTestExecutionContext(UnityTestExecutionContext other)
        {
            _priorContext = other;

            CurrentTest               = other.CurrentTest;
            CurrentResult             = other.CurrentResult;
            TestObject                = other.TestObject;
            WorkDirectory             = other.WorkDirectory;
            Listener                  = other.Listener;
            TestCaseTimeout           = other.TestCaseTimeout;
            UpstreamActions           = new List <ITestAction>(other.UpstreamActions);
            SetUpTearDownState        = other.SetUpTearDownState;
            OuterUnityTestActionState = other.OuterUnityTestActionState;

            TestContext.CurrentTestExecutionContext = this;

            CurrentCulture   = other.CurrentCulture;
            CurrentUICulture = other.CurrentUICulture;
            CurrentContext   = this;
        }
Пример #4
0
 public UnityTestAssemblyRunner(UnityTestAssemblyBuilder builder, WorkItemFactory factory)
 {
     unityBuilder = builder;
     m_Factory    = factory;
     Context      = new UnityTestExecutionContext();
 }