/// <summary> /// Runs the test, saving a TestResult in the supplied TestExecutionContext. /// </summary> /// <param name="context">The context in which the test should run.</param> /// <returns>A TestResult</returns> public override TestResult Execute(TestExecutionContext context) { try { TAsyncThreadMgr.GetInstance().ClearSetUpTearDown(); for (int i = _setUpTearDownItems.Count; i > 0;) { _setUpTearDownItems[--i].RunSetupForTC(context); } for (int i = 0; i < _setUpTearDownItems.Count; i++) { _setUpTearDownItems[i].RunTearDownForTC(context); } context.CurrentResult = innerCommand.Execute(context); } catch (Exception ex) { #if !NETCF && !SILVERLIGHT && !PORTABLE if (ex is ThreadAbortException) { Thread.ResetAbort(); } #endif context.CurrentResult.RecordException(ex); } return(context.CurrentResult); }
/// <summary> /// Execute the tests in the assembly, passing in /// a list of arguments. /// </summary> /// <param name="args">arguments for NUnitLite to use</param> public void Execute() { #if TIZEN #region tronghieu.d - Create new thread to run test and mainthread waiting for invoke test method. TAsyncThreadMgr asyncThreadMgr = TAsyncThreadMgr.GetInstance(); ManualResetEvent methodExecutionResetEvent = asyncThreadMgr.GetMethodExecutionResetEvent(); methodExecutionResetEvent.Reset(); Task t = Task.Run(() => { _textRunner.Execute(args); asyncThreadMgr.SetData(null, null, null, null, false); methodExecutionResetEvent.Set(); }); t.GetAwaiter().OnCompleted(() => { OnSingleTestDone(TSettings.GetInstance().GetSingleTestDoneEventArgs()); }); methodExecutionResetEvent.WaitOne(); asyncThreadMgr.RunTestMethod(); #endregion #else new TextRunner(_testAssembly).Execute(args); #endif }
public void RunSetupForTC(TestExecutionContext context) { _setUpWasRun = true; TAsyncThreadMgr asyncThreadMgr = TAsyncThreadMgr.GetInstance(); asyncThreadMgr.SetData(this); }
protected override void OnCreate() { base.OnCreate(); tlog.Debug(tag, "OnCreate() START!"); mainPid = Process.GetCurrentProcess().Id; mainTid = Thread.CurrentThread.ManagedThreadId; window = NUIApplication.GetDefaultWindow(); window.BackgroundColor = Color.Green; root = new View() { Size = new Size(100, 100), BackgroundColor = Color.White, PositionUsesPivotPoint = true, ParentOrigin = ParentOrigin.Center, PivotPoint = PivotPoint.Center, }; layer = window.GetDefaultLayer(); layer.Add(root); mainTitle = new TextLabel() { MultiLine = true, Text = title + $"Process ID: {Process.GetCurrentProcess().Id} \nThread ID: {Thread.CurrentThread.ManagedThreadId}\n", PixelSize = textSize, BackgroundColor = Color.Cyan, Size = new Size(window.WindowSize.Width * 0.9f, window.WindowSize.Height * 0.9f, 0), PositionUsesPivotPoint = true, ParentOrigin = ParentOrigin.Center, PivotPoint = PivotPoint.Center, }; root.Add(mainTitle); Thread.CurrentThread.Name = "main"; trunner = new NUnitLite.TUnit.TRunner(); trunner.LoadTestsuite(); asyncThreadMgr = TAsyncThreadMgr.GetInstance(); methodExecutionResetEvent = asyncThreadMgr.GetMethodExecutionResetEvent(); methodExecutionResetEvent.Reset(); Task t = Task.Run(() => { Thread.CurrentThread.Name = "textRunner"; trunner._textRunner.Execute(trunner.args); asyncThreadMgr.SetData(null, null, null, null, false); methodExecutionResetEvent.Set(); }); eventThreadCallback = new EventThreadCallback(new EventThreadCallback.CallbackDelegate(ProcessTest)); eventThreadCallback.Trigger(); }
public void RunTearDownForTC(TestExecutionContext context) { if (_setUpWasRun) { try { // Even though we are only running one level at a time, we // run the teardowns in reverse order to provide consistency. TAsyncThreadMgr asyncThreadMgr = TAsyncThreadMgr.GetInstance(); asyncThreadMgr.SetTearDownData(this); } catch (Exception ex) { context.CurrentResult.RecordTearDownException(ex); } } }