Esempio n. 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);
        }
Esempio n. 2
0
        public TestEntryPoint(ITestEntryPoint testEntryPoint, string resultsFileName)
        {
#pragma warning disable CS0618 // Type or member is obsolete
            var root = ((int)Build.VERSION.SdkInt) >= 30
                                ? global::Android.OS.Environment.ExternalStorageDirectory.AbsolutePath
                                : Application.Context.GetExternalFilesDir(null)?.AbsolutePath ?? FileSystem.AppDataDirectory;
#pragma warning restore CS0618 // Type or member is obsolete

            var docsDir = Path.Combine(root, "Documents");

            if (!Directory.Exists(docsDir))
            {
                Directory.CreateDirectory(docsDir);
            }

            _resultsPath    = Path.Combine(docsDir, resultsFileName);
            _testEntryPoint = testEntryPoint;
        }
Esempio n. 3
0
 public TestEntryPoint(ITestEntryPoint testEntryPoint)
 {
     _testEntryPoint = testEntryPoint;
 }