public MainPage() { this.InitializeComponent(); 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(AsyncTests).GetTypeInfo().Assembly); var resultsPath = Path.Combine(ApplicationData.Current.TemporaryFolder.Path, "Nunit", "Results.xml"); // 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. // NOTE: Your UWP App must have Private Networks capability enabled //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 = resultsPath, OnCompletedCallback = async() => { var resultFile = await StorageFile.GetFileFromPathAsync(resultsPath); var doc = await XmlDocument.LoadFromFileAsync(resultFile); var transformFile = Path.Combine(Package.Current.InstalledLocation.Path, "nunit3-junit.xslt"); var xslt = await StorageFile.GetFileFromPathAsync(transformFile); var xsltDoc = await XmlDocument.LoadFromFileAsync(xslt); var processor = new XsltProcessor(xsltDoc); var transformed = processor.TransformToDocument(doc.FirstChild); await transformed.SaveToFileAsync(resultFile); } }; LoadApplication(nunit); }
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 Runner.App(); // If you want to add tests in another assembly nunit.AddTestAssembly(typeof(AsyncTests).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, // 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 (ios file share / library directory) ResultFilePath = Path.Combine(NSFileManager.DefaultManager.GetUrls(NSSearchPathDirectory.LibraryDirectory, NSSearchPathDomain.User)[0].Path, "Results.xml"), LogToOutput = true, OnCompletedCallback = () => { // var selector = new ObjCRuntime.Selector("terminateWithSuccess"); // UIApplication.SharedApplication.PerformSelector(selector, UIKit.UIApplication.SharedApplication, 0); return(Task.FromResult(true)); } }; LoadApplication(nunit); return(base.FinishedLaunching(app, options)); }