Example #1
0
        /// <summary>
        /// Run selected tests and return a test result. The test is run synchronously,
        /// and the listener interface is notified as it progresses.
        /// </summary>
        /// <param name="listener">Interface to receive EventListener notifications.</param>
        /// <param name="filter">A test filter used to select tests to be run</param>
        /// <returns></returns>
        public ITestResult Run(ITestListener listener, ITestFilter filter)
        {
            TestExecutionContext context = new TestExecutionContext();

            if (this._settings.ContainsKey("WorkDirectory"))
            {
                context.WorkDirectory = (string)this._settings["WorkDirectory"];
            }
            else
            {
                context.WorkDirectory = Environment.CurrentDirectory;
            }

            context.Listener = listener;

            WorkItem workItem = new CompositeWorkItem(_loadedTest, filter);

            workItem.Execute(context);

            while (workItem.State != WorkItemState.Complete)
            {
                System.Threading.Thread.Sleep(5);
            }
            return(workItem.Result);
        }
Example #2
0
        public static CompositeWorkItem GenerateWorkItem(TestSuite suite, object testObject)
        {
            TestExecutionContext context = new TestExecutionContext();

            context.TestObject = testObject;

            CompositeWorkItem work = (CompositeWorkItem)WorkItem.CreateWorkItem(suite, TestFilter.Empty);

            work.InitializeContext(context);
            work.Execute();

            // TODO: Replace with an event - but not while method is static
            while (work.State != WorkItemState.Complete)
            {
#if PORTABLE
                System.Threading.Tasks.Task.Delay(1);
#else
                Thread.Sleep(1);
#endif
            }

            return(work);
        }