public async override void ViewDidLoad()
        {
            base.ViewDidLoad();
            var           options = ApplicationOptions.Current;
            TcpTextWriter writer  = null;

            if (!string.IsNullOrEmpty(options.HostName))
            {
                try {
                    writer = new TcpTextWriter(options.HostName, options.HostPort);
                } catch (Exception ex) {
                    Console.WriteLine("Network error: Cannot connect to {0}:{1}: {2}. Continuing on console.", options.HostName, options.HostPort, ex);
                    writer = null;                     // will default to the console
                }
            }

            // we generate the logs in two different ways depending if the generate xml flag was
            // provided. If it was, we will write the xml file to the tcp writer if present, else
            // we will write the normal console output using the LogWriter
            var logger = (writer == null || options.EnableXml) ? new LogWriter() : new LogWriter(writer);

            logger.MinimumLogLevel = MinimumLogLevel.Info;
            var testAssemblies = GetTestAssemblies();
            var runner         = RegisterType.IsXUnit ? (Xamarin.iOS.UnitTests.TestRunner) new XUnitTestRunner(logger) : new NUnitTestRunner(logger);
            var categories     = await IgnoreFileParser.ParseTraitsContentFileAsync(NSBundle.MainBundle.BundlePath, RegisterType.IsXUnit);

            // add category filters if they have been added
            runner.SkipCategories(categories);

            // if we have ignore files, ignore those tests
            var skippedTests = await IgnoreFileParser.ParseContentFilesAsync(NSBundle.MainBundle.BundlePath);

            if (skippedTests.Any())
            {
                // ensure that we skip those tests that have been passed via the ignore files
                runner.SkipTests(skippedTests);
            }
            await runner.Run(testAssemblies).ConfigureAwait(false);

            if (options.EnableXml)
            {
                runner.WriteResultsToFile(writer);
                logger.Info("Xml file was written to the tcp listener.");
            }
            else
            {
                string resultsFilePath = runner.WriteResultsToFile();
                logger.Info($"Xml result can be found {resultsFilePath}");
            }

            logger.Info($"Tests run: {runner.TotalTests} Passed: {runner.PassedTests} Inconclusive: {runner.InconclusiveTests} Failed: {runner.FailedTests} Ignored: {runner.FilteredTests}");
            if (options.TerminateAfterExecution)
            {
                BeginInvokeOnMainThread(TerminateWithSuccess);
            }
        }
Пример #2
0
        public async override void ViewDidLoad()
        {
            base.ViewDidLoad();
            var           options = ApplicationOptions.Current;
            TcpTextWriter writer  = null;

            if (!string.IsNullOrEmpty(options.HostName))
            {
                writer = new TcpTextWriter(options.HostName, options.HostPort);
            }

            // we generate the logs in two different ways depending if the generate xml flag was
            // provided. If it was, we will write the xml file to the tcp writer if present, else
            // we will write the normal console output using the LogWriter
            var logger = (writer == null || options.EnableXml) ? new LogWriter() : new LogWriter(writer);

            logger.MinimumLogLevel = MinimumLogLevel.Info;
            var testAssemblies = GetTestAssemblies();

            Xamarin.iOS.UnitTests.TestRunner runner;
            if (RegisterType.IsXUnit)
            {
                runner = new XUnitTestRunner(logger);
            }
            else
            {
                runner = new NUnitTestRunner(logger);
            }

            var skippedTests = await IgnoreFileParser.ParseContentFilesAsync(NSBundle.MainBundle.BundlePath);

            if (skippedTests.Any())
            {
                // ensure that we skip those tests that have been passed via the ignore files
                runner.SkipTests(skippedTests);
            }

            runner.Run((IList <TestAssemblyInfo>)testAssemblies);
            if (options.EnableXml)
            {
                runner.WriteResultsToFile(writer);
                logger.Info("Xml file was written to the tcp listener.");
            }
            else
            {
                string resultsFilePath = runner.WriteResultsToFile();
                logger.Info($"Xml result can be found {resultsFilePath}");
            }

            logger.Info($"Tests run: {runner.TotalTests} Passed: {runner.PassedTests} Inconclusive: {runner.InconclusiveTests} Failed: {runner.FailedTests} Ignored: {runner.SkippedTests}");
            if (options.TerminateAfterExecution)
            {
                TerminateWithSuccess();
            }
        }
Пример #3
0
        public async override void ViewDidLoad()
        {
            base.ViewDidLoad();
            var           options = ApplicationOptions.Current;
            TcpTextWriter writer  = null;

            if (!string.IsNullOrEmpty(options.HostName))
            {
                writer = new TcpTextWriter(options.HostName, options.HostPort);
            }

            // we generate the logs in two different ways depending if the generate xml flag was
            // provided. If it was, we will write the xml file to the tcp writer if present, else
            // we will write the normal console output using the LogWriter
            var logger = (writer == null || options.EnableXml) ? new LogWriter() : new LogWriter(writer);

            logger.MinimumLogLevel = MinimumLogLevel.Info;
            var testAssemblies = GetTestAssemblies();
            var runner         = RegisterType.IsXUnit ? (Xamarin.iOS.UnitTests.TestRunner) new XUnitTestRunner(logger) : new NUnitTestRunner(logger);
            var categories     = RegisterType.IsXUnit ?
                                 new List <string> {
                "failing",
                "nonmonotests",
                "outerloop",
                "nonosxtests"
            } :
            new List <string> {
                "MobileNotWorking",
                "NotOnMac",
                "NotWorking",
                "ValueAdd",
                "CAS",
                "InetAccess",
                "NotWorkingLinqInterpreter",
            };

            if (RegisterType.IsXUnit)
            {
                // special case when we are using the xunit runner,
                // there is a trait we are not interested in which is
                // the Benchmark one
                var xunitRunner = runner as XUnitTestRunner;
                xunitRunner.AddFilter(XUnitFilter.CreateTraitFilter("Benchmark", "true", true));
            }

            // add category filters if they have been added
            runner.SkipCategories(categories);

            // if we have ignore files, ignore those tests
            var skippedTests = await IgnoreFileParser.ParseContentFilesAsync(NSBundle.MainBundle.BundlePath);

            if (skippedTests.Any())
            {
                // ensure that we skip those tests that have been passed via the ignore files
                runner.SkipTests(skippedTests);
            }

            runner.Run((IList <TestAssemblyInfo>)testAssemblies);
            if (options.EnableXml)
            {
                runner.WriteResultsToFile(writer);
                logger.Info("Xml file was written to the tcp listener.");
            }
            else
            {
                string resultsFilePath = runner.WriteResultsToFile();
                logger.Info($"Xml result can be found {resultsFilePath}");
            }

            logger.Info($"Tests run: {runner.TotalTests} Passed: {runner.PassedTests} Inconclusive: {runner.InconclusiveTests} Failed: {runner.FailedTests} Ignored: {runner.FilteredTests}");
            if (options.TerminateAfterExecution)
            {
                TerminateWithSuccess();
            }
        }