static public CreateWorkItem ( ITest test, ITestFilter filter ) : WorkItem | ||
test | ITest | The test for which this WorkItem is being created. |
filter | ITestFilter | The filter to be used in selecting any child Tests. |
Результат | WorkItem |
private void CreateChildWorkItems() { _children = new List <WorkItem>(); foreach (ITest test in _suite.Tests) { if (_childFilter.Pass(test)) { var child = WorkItem.CreateWorkItem(test, _childFilter); child.WorkerId = this.WorkerId; #if !PORTABLE && !SILVERLIGHT && !NETCF if (child.TargetApartment == ApartmentState.Unknown && TargetApartment != ApartmentState.Unknown) { child.TargetApartment = TargetApartment; } #endif if (test.Properties.ContainsKey(PropertyNames.Order)) { _children.Insert(0, child); _countOrder++; } else { _children.Add(child); } } } if (_countOrder != 0) { SortChildren(); } }
public void CreateWorkItems() { IMethodInfo method = new MethodWrapper(typeof(DummyFixture), "DummyTest"); ITest test = new TestMethod(method); _workItem = WorkItem.CreateWorkItem(test, TestFilter.Empty); _context = new TestExecutionContext(); _workItem.InitializeContext(_context); }
private void CreateChildWorkItems() { _children = new List <WorkItem>(); foreach (Test test in _suite.Tests) { if (_childFilter.Pass(test)) { _children.Add(WorkItem.CreateWorkItem(test, _childFilter)); } } }
public void ParallelExeutionStrategy_TestFixture(ParallelScope testScope, ParallelScope contextScope, string expectedStrategy) { _testFixture.Properties.Set(PropertyNames.ParallelScope, testScope); _context.ParallelScope = contextScope; WorkItem work = WorkItem.CreateWorkItem(_testFixture, TestFilter.Empty); work.InitializeContext(_context); // We use a string for expected because the ExecutionStrategy enum is internal and can't be an arg to a public method Assert.That(ParallelWorkItemDispatcher.GetExecutionStrategy(work).ToString(), Is.EqualTo(expectedStrategy)); }
public void ParallelExecutionStrategy_TestCase(ParallelScope testScope, ParallelScope contextScope, string expectedStrategy) { _testMethod.Properties.Set(PropertyNames.ParallelScope, testScope); _context.ParallelScope = contextScope; WorkItem work = WorkItem.CreateWorkItem(_testMethod, TestFilter.Empty); work.InitializeContext(_context); // We use a string for expected because the ExecutionStrategy enum is internal and can't be an arg to a public method Assert.That(ParallelWorkItemDispatcher.GetExecutionStrategy(work).ToString(), Is.EqualTo(expectedStrategy)); // Make context single threaded - should always be direct _context.IsSingleThreaded = true; Assert.That(ParallelWorkItemDispatcher.GetExecutionStrategy(work).ToString(), Is.EqualTo("Direct")); }
private void RunChildren() { var children = new List <WorkItem>(); foreach (Test test in _suite.Tests) { if (_childFilter.Pass(test)) { children.Add(WorkItem.CreateWorkItem(test, new TestExecutionContext(this.Context), _childFilter)); } } if (children.Count > 0) { _childTestCountdown = new CountdownEvent(children.Count); foreach (WorkItem child in children) { child.Completed += new EventHandler(OnChildCompleted); #if NUNITLITE child.Execute(); #else if (Context.Dispatcher == null) { child.Execute(); } // For now, run all test cases on the same thread as the fixture // in order to handle ApartmentState preferences set on the fixture. else if (child is SimpleWorkItem || child.Test is ParameterizedMethodSuite) { log.Debug("Executing WorkItem for {0}", child.Test.FullName); child.Execute(); } else { Context.Dispatcher.Dispatch(child); } #endif } } }
private void RunChildren() { var children = new List <WorkItem>(); foreach (Test test in _suite.Tests) { if (_childFilter.Pass(test)) { children.Add(WorkItem.CreateWorkItem(test, new TestExecutionContext(this.Context), _childFilter)); } } if (children.Count > 0) { _childTestCountdown = new CountdownEvent(children.Count); foreach (WorkItem child in children) { child.Completed += new EventHandler(OnChildCompleted); #if NUNITLITE child.Execute(); #else // We run child items on the same thread as the parent... // 1. If there is no dispatcher (NUnitLite or LevelOfParallelism = 0). // 2. If there is no fixture, and so nothing to do but dispatch grandchildren. // 3. For now, if this represents a test case. This avoids issues of // tests that access the fixture state and allows handling ApartmentState // preferences set on the fixture. if (Context.Dispatcher == null || child is SimpleWorkItem || child.Test.FixtureType == null) { log.Debug("Directly executing {0}", child.Test.Name); child.Execute(); } else { Context.Dispatcher.Dispatch(child); } #endif } } }