Load() public method

Loads the tests found in an Android.NUnitLite
public Load ( Assembly assembly, IDictionary settings ) : bool
assembly System.Reflection.Assembly
settings IDictionary Dictionary of option settings for loading the Android.NUnitLite
return bool
コード例 #1
0
        public static void RunTests()
        {
            ITestAssemblyRunner testRunner = new NUnitLiteTestAssemblyRunner (new NUnitLiteTestAssemblyBuilder ());

            Assembly assembly = Assembly.GetCallingAssembly ();

            bool hasTestLoaded = testRunner.Load (assembly: assembly, settings: new Hashtable ());
            if (!hasTestLoaded) {
                Debug.Log (string.Format ("No tests found in assembly {0}", assembly.GetName ().Name));
                return;
            }

            ITestResult rootTestResult = testRunner.Run (TestListener.NULL, TestFilter.Empty);

            ResultSummary summary = new ResultSummary (rootTestResult);
            Debug.Log (ToSummryString (summary));

            List<ITestResult> testResultList = EnumerateTestResult (rootTestResult).Where (it => !it.HasChildren).ToList ();

            if (summary.FailureCount > 0 || summary.ErrorCount > 0) {
                DebugLogErrorResults (testResultList);
            }

            if (summary.NotRunCount > 0) {
                DebugLogNotRunResults (testResultList);
            }
        }
コード例 #2
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);
                    }
                }
            });
        }
コード例 #3
0
        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);
        }
コード例 #4
0
ファイル: UnitTestSection.cs プロジェクト: gene-l-thomas/Eto
		async void RunTests(CategoryFilter filter = null)
		{
			if (!startButton.Enabled)
				return;
			startButton.Enabled = false;
			Log.Write(null, "Starting tests...");
			var testPlatform = useTestPlatform.Checked == true ? new TestPlatform() : Platform;
			try
			{
				await Task.Run(() =>
				{
					using (Platform.ThreadStart())
					{
						try
						{
							var assembly = GetType().GetTypeInfo().Assembly;
							var runner = new NUnitLiteTestAssemblyRunner(new NUnitLiteTestAssemblyBuilder());
							if (!runner.Load(assembly, new Dictionary<string, object>()))
							{
								Log.Write(null, "Failed to load test assembly");
								return;
							}
							ITestResult result;
							var listener = new TestListener { Application = Application.Instance }; // use running application for logging
							filter = filter ?? new CategoryFilter();
							filter.Application = Application.Instance;
							if (testPlatform is TestPlatform)
							{
								filter.ExcludeCategories.Add(UnitTests.TestUtils.NoTestPlatformCategory);
							}
							using (testPlatform.Context)
							{
								result = runner.Run(listener, filter);
							}
							var writer = new StringWriter();
							writer.WriteLine(result.FailCount > 0 ? "FAILED" : "PASSED");
							writer.WriteLine("\tPass: {0}, Fail: {1}, Skipped: {2}, Inconclusive: {3}", result.PassCount, result.FailCount, result.SkipCount, result.InconclusiveCount);
							writer.Write("\tDuration: {0}", result.Duration);
							Application.Instance.Invoke(() => Log.Write(null, writer.ToString()));
						}
						catch (Exception ex)
						{
							Application.Instance.Invoke(() => Log.Write(null, "Error running tests: {0}", ex));
						}
						finally
						{
							Application.Instance.Invoke(() => startButton.Enabled = true);
						}
					}
				});
			}
			catch (Exception ex)
			{
				Log.Write(null, "Error running tests\n{0}", ex);
			}
		}