public bool Execute(string[] args) { IDictionary <string, string> parameters = InitializeParameters(args); if (parameters == null) { return(false); } if (parameters.ContainsKey("InterfaceDefinitionPath")) { if (InitializeProviderPluginDirectory(parameters["InterfaceDefinitionPath"]) == false) { return(false); } ExecutionVariables environmentVariables = new ExecutionVariables() { Broadcaster = Broadcaster, InterfaceDefinitionDirectoryPath = parameters["InterfaceDefinitionPath"], }; try { Broadcaster.Info("Using interface definition from '{0}'", parameters["InterfaceDefinitionPath"]); _CurrentRunner = new ExecutionManager(); if (_CurrentRunner.Initialize(environmentVariables) == false) { return(false); } } catch (Exception ex) { Broadcaster.Error("An unexpected error occured while initializing the InterfaceDefinitionRunner: '{0}'.", ex.Message); return(false); } if (parameters.ContainsKey("RunJob")) { return(_CurrentRunner.RunJob(parameters["RunJob"]).IsSuccess); } else { Broadcaster.Error("The startup parameter 'RunJob' must be set."); return(false); } } else { Broadcaster.Error("The startup parameter 'InterfaceDefinitionPath' must be set."); return(false); } }
/// <summary> /// Invoked when the application is launched normally by the end user. Other entry points /// will be used such as when the application is launched to open a specific file. /// </summary> /// <param name="e">Details about the launch request and process.</param> protected override void OnLaunched(LaunchActivatedEventArgs e) { #if DEBUG if (System.Diagnostics.Debugger.IsAttached) { DebugSettings.EnableFrameRateCounter = true; } #endif var rootFrame = Window.Current.Content as Frame; // Do not repeat app initialization when the Window already has content, // just ensure that the window is active if (rootFrame == null) { // Create a Frame to act as the navigation context and navigate to the first page rootFrame = new Frame(); rootFrame.NavigationFailed += OnNavigationFailed; if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) { //TODO: Load state from previously suspended application } // Place the frame in the current Window Window.Current.Content = rootFrame; } Microsoft.VisualStudio.TestPlatform.TestExecutor.UnitTestClient.CreateDefaultUI(); // Ensure the current window is active Window.Current.Activate(); //Microsoft.VisualStudio.TestPlatform.TestExecutor.UnitTestClient.Run(e.Arguments); var dm = new DiscoveryManager(new RequestData() { IsTelemetryOptedIn = false, ProtocolConfig = new ProtocolConfig { Version = 2 }, MetricsCollection = new NoOpMetricsCollection() }); // Adapter output location #if DEBUG var source = "entrypoint\\test.harness.uwp.exe"; #else var source = "test.harness.uwp.exe"; #endif var adapterPath = Path.Combine(Package.Current.InstalledLocation.Path, "xunit.runner.visualstudio.uwp.testadapter.dll"); var hander = new MockTestDiscoveryEventHandler(); var criteria = new DiscoveryCriteria(new[] { "" }, long.MaxValue, string.Empty);; criteria.AdapterSourceMap.Clear(); criteria.AdapterSourceMap.Add(adapterPath, new[] { source }); hander.OnDiscoveryCompleted += (sender, args) => { // Run var em1 = new ExecutionManager(new RequestData() { IsTelemetryOptedIn = false, ProtocolConfig = new ProtocolConfig { Version = 2 }, MetricsCollection = new NoOpMetricsCollection() }); // Run Specific tests em1.Initialize(new[] { adapterPath }); var tec1 = new TestExecutionContext(); em1.StartTestRun(hander.TestCases, "", "", tec1, new MockTestCaseEventsHandler(), new MockRunEventsHandler()); }; dm.DiscoverTests(criteria, hander); //Run All -- Not working yet //var em = new ExecutionManager(new RequestData() //{ // IsTelemetryOptedIn = false, // ProtocolConfig = new ProtocolConfig // { // Version = 2 // }, // MetricsCollection = new NoOpMetricsCollection() //}); // var tec = new TestExecutionContext(); // em.Initialize(new[] { adapterPath }); //em.StartTestRun(criteria.AdapterSourceMap, "", "", tec, new MockTestCaseEventsHandler(), new MockRunEventsHandler()); }