Default implementation of ITestAssemblyRunner
Inheritance: ITestAssemblyRunner
Esempio n. 1
0
        protected override void OnResume()
        {
            base.OnResume();

            var testAssemblies         = GetAssembliesForTest();
            var testAssemblyEnumerator = testAssemblies.GetEnumerator();
            var testRunner             = new NUnit.Framework.Internal.NUnitLiteTestAssemblyRunner(new NUnitLiteTestAssemblyBuilder());

            // Clear the test result list
            TestRunContext.Current.TestResults.Clear();

            _testResultsAdapter.NotifyDataSetInvalidated();
            _testResultsAdapter.NotifyDataSetChanged();

            // Add a test listener for the test runner
            var listener = new UITestListener((TestResultsListAdapter)ListAdapter);

            // Start the test process in a background task
            Task.Factory.StartNew(() =>
            {
                var emptyFilter = new EmptyFilter();
                while (testAssemblyEnumerator.MoveNext())
                {
                    try
                    {
                        var assembly = testAssemblyEnumerator.Current;
                        if (!testRunner.Load(assembly, new Hashtable()))
                        {
                            AssemblyName assemblyName = AssemblyHelper.GetAssemblyName(assembly);
                            Console.WriteLine("No tests found in assembly {0}", assemblyName.Name);
                            return;
                        }

                        testRunner.Run(
                            listener,
                            emptyFilter);
                    }
                    catch (Exception ex)
                    {
                        ShowErrorDialog(ex);
                    }
                }
            });
        }
        public static void RunTests(ITestFilter filter)
        {
            var testRunner = new NUnit.Framework.Internal.NUnitLiteTestAssemblyRunner (new NUnit.Framework.Internal.NUnitLiteTestAssemblyBuilder ());

            var settings = new Dictionary<string, IList> {
                //{ "LOAD", new List<string> { "Couchbase.Lite.ReplicationTest" } }
            };

            Assembly assembly = Assembly.Load ("Couchbase.Lite.Unity.Tests");
            bool hasTestLoaded = testRunner.Load (assembly, settings);
            if (!hasTestLoaded) {
                Debug.Log ("No tests found in assembly");
                return;
            }

            Task.Factory.StartNew (() => {
                testRunner.Run(new UnityListener(), filter);
            }, TaskCreationOptions.LongRunning);
        }