Esempio n. 1
0
        //
        // This method is invoked when the application has loaded and is ready to run. In this 
        // method you should instantiate the window, load the UI into it and then make the window
        // visible.
        //
        // You have 17 seconds to return from this method, or iOS will terminate your application.
        //
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            // We need this to ensure the execution assembly is part of the app bundle
            AddExecutionAssembly(typeof(ExtensibilityPointFactory).Assembly);
            

            // tests can be inside the main assembly
            AddTestAssembly(typeof(TcpSocketClientTests).Assembly);

#if false
			// you can use the default or set your own custom writer (e.g. save to web site and tweet it ;-)
			Writer = new TcpTextWriter ("10.0.1.2", 16384);
			// start running the test suites as soon as the application is loaded
			AutoStart = true;
			// crash the application (to ensure it's ended) and return to springboard
			TerminateAfterExecution = true;
#endif
            return base.FinishedLaunching(app, options);
		}
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            // We need this to ensure the execution assembly is part of the app bundle
            AddExecutionAssembly(typeof(ExtensibilityPointFactory).Assembly);


            // tests can be inside the main assembly
            AddTestAssembly(Assembly.GetExecutingAssembly());
            // otherwise you need to ensure that the test assemblies will
            // become part of the app bundle
            //AddTestAssembly(typeof(PortableTests).Assembly);

            #if false
            // you can use the default or set your own custom writer (e.g. save to web site and tweet it ;-)
            Writer = new TcpTextWriter("10.0.1.2", 16384);
            // start running the test suites as soon as the application is loaded
            AutoStart = true;
            // crash the application (to ensure it's ended) and return to springboard
            TerminateAfterExecution = true;
            #endif

            return(base.FinishedLaunching(app, options));
        }
Esempio n. 3
0
        protected override void OnCreate(Bundle bundle)
        {
            // tests can be inside the main assembly
            AddTestAssembly(Assembly.GetExecutingAssembly());

            AddExecutionAssembly(typeof(ExtensibilityPointFactory).Assembly);
            // or in any reference assemblies

            //AddTestAssembly(typeof(PortableTests).Assembly);
            AddTestAssembly(typeof(CoreUnitTestsEntryPoint).Assembly);
            // or in any assembly that you load (since JIT is available)

#if false
            // you can use the default or set your own custom writer (e.g. save to web site and tweet it ;-)
            Writer = new TcpTextWriter("10.0.1.2", 16384);
            // start running the test suites as soon as the application is loaded
            AutoStart = true;
            // crash the application (to ensure it's ended) and return to springboard
            TerminateAfterExecution = true;
#endif
            // you cannot add more assemblies once calling base
            base.OnCreate(bundle);
        }
Esempio n. 4
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            // tests can be inside the main assembly
            //AddTestAssembly(Assembly.GetExecutingAssembly());

            AddExecutionAssembly(typeof(ExtensibilityPointFactory).Assembly);
            // or in any reference assemblies

            AddTestAssembly(typeof(Microsoft.Graph.DotnetCore.Core.Test.Requests.GraphClientFactoryTests).Assembly);
            // or in any assembly that you load (since JIT is available)

#if false
            // you can use the default or set your own custom writer (e.g. save to web site and tweet it ;-)
            Writer = new TcpTextWriter("10.0.1.2", 16384);
            // start running the test suites as soon as the application is loaded
            AutoStart = true;
            // crash the application (to ensure it's ended) and return to springboard
            TerminateAfterExecution = true;
#endif
            // you cannot add more assemblies once calling base
            base.OnCreate(savedInstanceState);
            //Xamarin.Essentials.Platform.Init(this, savedInstanceState);
        }
        public override bool FinishedLaunching(UIApplication uiApplication, NSDictionary launchOptions)
        {
            _manager.RequestAlwaysAuthorization();

            // We need this to ensure the execution assembly is part of the app bundle
            AddExecutionAssembly(typeof(ExtensibilityPointFactory).Assembly);

            // tests can be inside the main assembly
            AddTestAssembly(Assembly.GetExecutingAssembly());
            // otherwise you need to ensure that the test assemblies will
            // become part of the app bundle
            //AddTestAssembly(typeof(PortableTests).Assembly);

            #if false
            // you can use the default or set your own custom writer (e.g. save to web site and tweet it ;-)
            Writer = new TcpTextWriter ("10.0.1.2", 16384);
            // start running the test suites as soon as the application is loaded
            AutoStart = true;
            // crash the application (to ensure it's ended) and return to springboard
            TerminateAfterExecution = true;
            #endif

            return base.FinishedLaunching(uiApplication, launchOptions);
        }
Esempio n. 6
0
        protected override void OnCreate(Bundle bundle)
        {
            // tests can be inside the main assembly
            //(CDLTLL) AddTestAssembly(Assembly.GetExecutingAssembly());

            // We need this to ensure the execution assembly is part of the app bundle
            AddExecutionAssembly(typeof(ExtensibilityPointFactory).Assembly);

            // or in any reference assemblies getting the Assembly from any type/class
            AddTestAssembly(typeof(MyWorld.ClientApps.UnitTests.DummyTests).Assembly);

            // or in any assembly that you load (since JIT is available)

#if false
            // you can use the default or set your own custom writer (e.g. save to web site and tweet it ;-)
            Writer = new TcpTextWriter("10.0.1.2", 16384);
            // start running the test suites as soon as the application is loaded
            AutoStart = true;
            // crash the application (to ensure it's ended) and return to springboard
            TerminateAfterExecution = true;
#endif
            // you cannot add more assemblies once calling base
            base.OnCreate(bundle);
        }
Esempio n. 7
0
        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);

            Xamarin.iOS.UnitTests.TestRunner.Jargon jargon = Xamarin.iOS.UnitTests.TestRunner.Jargon.NUnitV3;
            switch (options.XmlVersion)
            {
            default:
            case XmlVersion.NUnitV2:
                jargon = Xamarin.iOS.UnitTests.TestRunner.Jargon.NUnitV2;
                break;

            case XmlVersion.NUnitV3:
                jargon = Xamarin.iOS.UnitTests.TestRunner.Jargon.NUnitV3;
                break;
            }
            if (options.EnableXml)
            {
                runner.WriteResultsToFile(writer ?? Console.Out, jargon);
                logger.Info("Xml file was written to the tcp listener.");
            }
            else
            {
                string resultsFilePath = runner.WriteResultsToFile(jargon);
                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);
            }
        }
Esempio n. 8
0
        public bool OpenWriter(string message)
        {
            TouchOptions options = TouchOptions.Current;
            DateTime     now     = DateTime.Now;

            // let the application provide it's own TextWriter to ease automation with AutoStart property
            if (Writer == null)
            {
                if (options.ShowUseNetworkLogger)
                {
                    try {
                        string hostname = null;
                        WriterFinishedTask = null;
                        TextWriter defaultWriter = null;
                        switch (options.Transport)
                        {
                        case "FILE":
                            Console.WriteLine("[{0}] Sending '{1}' results to the file {2}", now, message, options.LogFile);
                            defaultWriter = new StreamWriter(options.LogFile, true, System.Text.Encoding.UTF8)
                            {
                                AutoFlush = true,
                            };
                            break;

                        case "HTTP":
                            var hostnames = options.HostName.Split(',');
                            hostname = hostnames [0];
                            if (hostnames.Length > 1)
                            {
                                Console.WriteLine("[{0}] Found multiple host names ({1}); will only try sending to the first ({2})", now, options.HostName, hostname);
                            }
                            Console.WriteLine("[{0}] Sending '{1}' results to {2}:{3}", now, message, hostname, options.HostPort);
                            var w = new HttpTextWriter()
                            {
                                HostName = hostname,
                                Port     = options.HostPort,
                            };
                            w.Open();
                            defaultWriter      = w;
                            WriterFinishedTask = w.FinishedTask;
                            break;

                        default:
                            Console.WriteLine("Unknown transport '{0}': switching to default (TCP)", options.Transport);
                            goto case "TCP";

                        case "TCP":
                            hostname = SelectHostName(options.HostName.Split(','), options.HostPort);
                            if (string.IsNullOrEmpty(hostname))
                            {
                                break;
                            }
                            Console.WriteLine("[{0}] Sending '{1}' results to {2}:{3}", now, message, hostname, options.HostPort);
                            defaultWriter = new TcpTextWriter(hostname, options.HostPort);
                            break;
                        }
                        if (options.EnableXml)
                        {
                            Writer = new NUnitOutputTextWriter(
                                this, defaultWriter, new NUnitLite.Runner.NUnit2XmlOutputWriter(DateTime.UtcNow), options.XmlMode);
                        }
                        else
                        {
                            Writer = defaultWriter;
                        }
                    } catch (Exception ex) {
                        connection_failure = true;
                        if (!ShowConnectionErrorAlert(options.HostName, options.HostPort, ex))
                        {
                            return(false);
                        }

                        Console.WriteLine("Network error: Cannot connect to {0}:{1}: {2}. Continuing on console.", options.HostName, options.HostPort, ex);
                        Writer = Console.Out;
                    }
                }
            }

            if (Writer == null)
            {
                Writer = Console.Out;
            }

            Writer.WriteLine("[Runner executing:\t{0}]", message);
            Writer.WriteLine("[MonoTouch Version:\t{0}]", Constants.Version);
            Writer.WriteLine("[Assembly:\t{0}.dll ({1} bits)]", typeof(NSObject).Assembly.GetName().Name, IntPtr.Size * 8);
            Writer.WriteLine("[GC:\t{0}]", GC.MaxGeneration == 0 ? "Boehm": "sgen");
            WriteDeviceInformation(Writer);
            Writer.WriteLine("[Device Locale:\t{0}]", NSLocale.CurrentLocale.Identifier);
            Writer.WriteLine("[Device Date/Time:\t{0}]", now);              // to match earlier C.WL output

            Writer.WriteLine("[Bundle:\t{0}]", NSBundle.MainBundle.BundleIdentifier);
            // FIXME: add data about how the app was compiled (e.g. ARMvX, LLVM, GC and Linker options)
            PassedCount       = 0;
            IgnoredCount      = 0;
            FailedCount       = 0;
            InconclusiveCount = 0;
            return(true);
        }
Esempio n. 9
0
        public bool OpenWriter(string message)
        {
            TouchOptions options = TouchOptions.Current;
            DateTime     now     = DateTime.Now;

            // let the application provide it's own TextWriter to ease automation with AutoStart property
            if (Writer == null)
            {
                if (options.ShowUseNetworkLogger)
                {
                    var hostname = SelectHostName(options.HostName.Split(','), options.HostPort);

                    if (hostname != null)
                    {
                        Console.WriteLine("[{0}] Sending '{1}' results to {2}:{3}", now, message, hostname, options.HostPort);
                        try {
                            WriterFinishedTask = null;
                            switch (options.Transport)
                            {
                            case "HTTP":
                                var w = new HttpTextWriter()
                                {
                                    HostName = hostname,
                                    Port     = options.HostPort,
                                };
                                w.Open();
                                Writer             = w;
                                WriterFinishedTask = w.FinishedTask;
                                break;

                            default:
                                Console.WriteLine("Unknown transport '{0}': switching to default (TCP)", options.Transport);
                                goto case "TCP";

                            case "TCP":
                                Writer = new TcpTextWriter(hostname, options.HostPort);
                                break;
                            }
                        }
                        catch (Exception ex) {
#if __TVOS__ || __WATCHOS__
                            Console.WriteLine("Network error: Cannot connect to {0}:{1}: {2}. Continuing on console.", hostname, options.HostPort, ex);
                            Writer = Console.Out;
#else
                            Console.WriteLine("Network error: Cannot connect to {0}:{1}: {2}.", hostname, options.HostPort, ex);
                            UIAlertView alert = new UIAlertView("Network Error",
                                                                String.Format("Cannot connect to {0}:{1}: {2}. Continue on console ?", hostname, options.HostPort, ex.Message),
                                                                null, "Cancel", "Continue");
                            int button = -1;
                            alert.Clicked += delegate(object sender, UIButtonEventArgs e) {
                                button = (int)e.ButtonIndex;
                            };
                            alert.Show();
                            while (button == -1)
                            {
                                NSRunLoop.Current.RunUntil(NSDate.FromTimeIntervalSinceNow(0.5));
                            }
                            Console.WriteLine(button);
                            Console.WriteLine("[Host unreachable: {0}]", button == 0 ? "Execution cancelled" : "Switching to console output");
                            if (button == 0)
                            {
                                return(false);
                            }
                            else
                            {
                                Writer = Console.Out;
                            }
#endif
                        }
                    }
                }
                else
                {
                    Writer = Console.Out;
                }
            }

            Writer.WriteLine("[Runner executing:\t{0}]", message);
            Writer.WriteLine("[MonoTouch Version:\t{0}]", Constants.Version);
            Writer.WriteLine("[Assembly:\t{0}.dll ({1} bits)]", typeof(NSObject).Assembly.GetName().Name, IntPtr.Size * 8);
            Writer.WriteLine("[GC:\t{0}]", GC.MaxGeneration == 0 ? "Boehm": "sgen");
            WriteDeviceInformation(Writer);
            Writer.WriteLine("[Device Locale:\t{0}]", NSLocale.CurrentLocale.Identifier);
            Writer.WriteLine("[Device Date/Time:\t{0}]", now);              // to match earlier C.WL output

            Writer.WriteLine("[Bundle:\t{0}]", NSBundle.MainBundle.BundleIdentifier);
            // FIXME: add data about how the app was compiled (e.g. ARMvX, LLVM, GC and Linker options)
            PassedCount       = 0;
            IgnoredCount      = 0;
            FailedCount       = 0;
            InconclusiveCount = 0;
            return(true);
        }
Esempio n. 10
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();
            }
        }
Esempio n. 11
0
		public bool OpenWriter (string message)
		{
			TouchOptions options = TouchOptions.Current;
			DateTime now = DateTime.Now;
			// let the application provide it's own TextWriter to ease automation with AutoStart property
			if (Writer == null) {
				if (options.ShowUseNetworkLogger) {
					var hostname = SelectHostName (options.HostName.Split (','), options.HostPort);

					if (hostname != null) {
						Console.WriteLine ("[{0}] Sending '{1}' results to {2}:{3}", now, message, hostname, options.HostPort);
						try {
							WriterFinishedTask = null;
							TextWriter defaultWriter = null;
							switch (options.Transport) {
							case "HTTP":
								var w = new HttpTextWriter ()
								{
									HostName = hostname,
									Port = options.HostPort,
								};
								w.Open ();
								defaultWriter = w;
								WriterFinishedTask = w.FinishedTask;
								break;
							default:
								Console.WriteLine ("Unknown transport '{0}': switching to default (TCP)", options.Transport);
								goto case "TCP";
							case "TCP":
								defaultWriter = new TcpTextWriter (hostname, options.HostPort);
								break;
							}
							if (options.EnableXml) {
								Writer = new NUnitOutputTextWriter (
									this, defaultWriter, new NUnitLite.Runner.NUnit2XmlOutputWriter (DateTime.UtcNow));
							} else {
								Writer = defaultWriter;
							}
						}
						catch (Exception ex) {
#if __TVOS__ || __WATCHOS__
							Console.WriteLine ("Network error: Cannot connect to {0}:{1}: {2}. Continuing on console.", hostname, options.HostPort, ex);
							Writer = Console.Out;
#else
							Console.WriteLine ("Network error: Cannot connect to {0}:{1}: {2}.", hostname, options.HostPort, ex);
							UIAlertView alert = new UIAlertView ("Network Error", 
								String.Format ("Cannot connect to {0}:{1}: {2}. Continue on console ?", hostname, options.HostPort, ex.Message), 
								null, "Cancel", "Continue");
							int button = -1;
							alert.Clicked += delegate(object sender, UIButtonEventArgs e) {
								button = (int)e.ButtonIndex;
							};
							alert.Show ();
							while (button == -1)
								NSRunLoop.Current.RunUntil (NSDate.FromTimeIntervalSinceNow (0.5));
							Console.WriteLine (button);
							Console.WriteLine ("[Host unreachable: {0}]", button == 0 ? "Execution cancelled" : "Switching to console output");
							if (button == 0)
								return false;
							else
								Writer = Console.Out;
#endif
						}
					}
				} else {
					Writer = Console.Out;
				}
			}

			Writer.WriteLine ("[Runner executing:\t{0}]", message);
			Writer.WriteLine ("[MonoTouch Version:\t{0}]", Constants.Version);
			Writer.WriteLine ("[Assembly:\t{0}.dll ({1} bits)]", typeof (NSObject).Assembly.GetName ().Name, IntPtr.Size * 8);
			Writer.WriteLine ("[GC:\t{0}]", GC.MaxGeneration == 0 ? "Boehm": "sgen");
			WriteDeviceInformation (Writer);
			Writer.WriteLine ("[Device Locale:\t{0}]", NSLocale.CurrentLocale.Identifier);
			Writer.WriteLine ("[Device Date/Time:\t{0}]", now); // to match earlier C.WL output

			Writer.WriteLine ("[Bundle:\t{0}]", NSBundle.MainBundle.BundleIdentifier);
			// FIXME: add data about how the app was compiled (e.g. ARMvX, LLVM, GC and Linker options)
			PassedCount = 0;
			IgnoredCount = 0;
			FailedCount = 0;
			InconclusiveCount = 0;
			return true;
		}