コード例 #1
0
        public static async Task <Bundle> RunTestsAsync(ITestEntryPoint testEntryPoint, Bundle arguments = null)
        {
            var resultsFileName = arguments?.GetString("results-file-name", DefaultTestResultsFilename) ?? DefaultTestResultsFilename;

            var bundle = new Bundle();

            var entryPoint = new TestEntryPoint(testEntryPoint, resultsFileName);

            entryPoint.TestsCompleted += (sender, results) =>
            {
                var message =
                    $"Tests run: {results.ExecutedTests} " +
                    $"Passed: {results.PassedTests} " +
                    $"Inconclusive: {results.InconclusiveTests} " +
                    $"Failed: {results.FailedTests} " +
                    $"Ignored: {results.SkippedTests}";
                bundle.PutString("test-execution-summary", message);

                bundle.PutLong("return-code", results.FailedTests == 0 ? 0 : 1);
            };

            await entryPoint.RunAsync();

            if (File.Exists(entryPoint.TestsResultsFinalPath))
            {
                bundle.PutString("test-results-path", entryPoint.TestsResultsFinalPath);
            }

            if (bundle.GetLong("return-code", -1) == -1)
            {
                bundle.PutLong("return-code", 1);
            }

            return(bundle);
        }
コード例 #2
0
        public override async void ViewDidLoad()
        {
            base.ViewDidLoad();

            var entryPoint = new TestEntryPoint(_applicationDelegate);

            await entryPoint.RunAsync();
        }
コード例 #3
0
ファイル: BaseTestActivity.cs プロジェクト: zhamppx97/maui
        protected override async void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            var arguments = Intent?.GetBundleExtra(ArgumentsBundleKey);

            try
            {
                Bundle bundle = await TestEntryPoint.RunTestsAsync(this, arguments);

                TaskCompletionSource.TrySetResult(bundle);
            }
            catch (Exception ex)
            {
                TaskCompletionSource.TrySetException(ex);
            }

            Finish();
        }