The NUnit Xamarin test runner
Inheritance: Xamarin.Forms.Application
示例#1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            global::Xamarin.Forms.Forms.Init(this, savedInstanceState);


            ConfigurationManager.Initialise(PCLAppConfig.FileSystemStream.PortableStream.Current);
            using (StreamReader sr = new StreamReader(Application.Assets.Open("crypto_compatibility_data.json")))
            {
                var content = sr.ReadToEnd();
                AppSettings.CryptoCompatibilityData = content;
            }

            // This will load all tests within the current project
            var nunit = new NUnit.Runner.App();

            // If you want to add tests in another assembly
            //nunit.AddTestAssembly(typeof(MyTests).Assembly);

            // Do you want to automatically run tests when the app starts?
            nunit.Options = new TestOptions
            {
                AutoRun = true
            };

            LoadApplication(nunit);
        }
示例#2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            global::Xamarin.Forms.Forms.Init(this, savedInstanceState);

            // This will load all tests within the current project
            App nunit = new NUnit.Runner.App();

            // If you want to add tests in another assembly
            nunit.AddTestAssembly(typeof(Common.UnitTests.ExampleTests).Assembly);

            // Available options for testing
            nunit.Options = new TestOptions
            {
                // If True, the tests will run automatically when the app starts
                // otherwise you must run them manually.
                AutoRun = true,

                // If True, the application will terminate automatically after running the tests.
                ////TerminateAfterExecution = true,

                // Information about the tcp listener host and port.
                // For now, send result as XML to the listening server.
                ////TcpWriterParameters = new TcpWriterInfo("192.168.0.108", 13000),

                // Creates a NUnit Xml result file on the host file system using PCLStorage library.
                //// CreateXmlResultFile = true,

                // Choose a different path for the xml result file
                //// ResultFilePath = Path.Combine(Environment.ExternalStorageDirectory.Path, Environment.DirectoryDownloads, "Nunit", "Results.xml")
            };

            this.LoadApplication(nunit);
        }
示例#3
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            global::Xamarin.Forms.Forms.Init(this, savedInstanceState);

            // This will load all tests within the current project
            var nunit = new NUnit.Runner.App();

            // If you want to add tests in another assembly
            //nunit.AddTestAssembly(typeof(SomeTests).Assembly);
            //var anassembly = typeof(global::Lucene.Net.Util.Test2BPagedBytes).Assembly;
            nunit.AddTestAssembly(Settings.TargetAssembly);

            // Available options for testing
            nunit.Options = new TestOptions
            {
                // If True, the tests will run automatically when the app starts
                // otherwise you must run them manually.
                //AutoRun = true,

                // If True, the application will terminate automatically after running the tests.
                //TerminateAfterExecution = true,

                // Information about the tcp listener host and port.
                // For now, send result as XML to the listening server.
                //TcpWriterParameters = new TcpWriterInfo("192.168.0.108", 13000),

                // Creates a NUnit Xml result file on the host file system using PCLStorage library.
                CreateXmlResultFile = true,

                // Choose a different path for the xml result file
                ResultFilePath = Path.Combine(Application.Context.GetExternalFilesDir("").AbsolutePath, Settings.TestResultFileName)
            };

            LoadApplication(nunit);


            //// Use the runner directly with BlameListener to detect which tests crash the runner
            //string blameFilePath = Path.Combine(Application.Context.GetExternalFilesDir("").AbsolutePath, Settings.BlameFileName);
            //using (var blameWriter = new StreamWriter(blameFilePath, append: false, encoding: System.Text.Encoding.UTF8))
            //{
            //    NUnitTestAssemblyRunner runner = new NUnitTestAssemblyRunner(new DefaultTestAssemblyBuilder());
            //    runner.Load(Settings.TargetAssembly, new Dictionary<string, object>());

            //    var filter = new MyFilter();
            //    //var filter = TestFilter.Empty;


            //    ITestResult result = runner.Run(new BlameListener(TestListener.NULL, blameWriter), filter);
            //    var startTime = DateTime.Now;
            //    var resultsXml = new NUnit3XmlOutputWriter(startTime);
            //    resultsXml.WriteResultFile(result, nunit.Options.ResultFilePath);
            //}
        }
示例#4
0
        public MainPage()
        {
            InitializeComponent();

            // Windows Universal will not load all tests within the current project,
            // you must do it explicitly below
            var nunit = new Runner.App();

            // If you want to add tests in another assembly, add a reference and
            // duplicate the following line with a type from the referenced assembly
            nunit.AddTestAssembly(typeof(MainPage).GetTypeInfo().Assembly);

            // Do you want to automatically run tests when the app starts?
            nunit.AutoRun = true;

            LoadApplication(nunit);
        }
示例#5
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)
        {
            global::Xamarin.Forms.Forms.Init();

            // This will load all tests within the current project
            var nunit = new NUnit.Runner.App();

            // If you want to add tests in another assembly
            ConfigurationManager.Initialise(PCLAppConfig.FileSystemStream.PortableStream.Current);
            var text = System.IO.File.ReadAllText("crypto_compatibility_data.json");

            AppSettings.CryptoCompatibilityData = text;
            // Do you want to automatically run tests when the app starts?
            nunit.Options = new TestOptions
            {
                AutoRun = true
            };

            LoadApplication(nunit);

            return(base.FinishedLaunching(app, options));
        }