public async Task Init(CancellationTokenSource cts)
        {
            if (initialized == true)
            {
                return;
            }

            AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;

            diagnostics = CreateDiagnostics(cts);
            var installation = Installations.Value.First(i => i.ApplicationPath == InstancePath);
            var hive         = new VsHive(installation, Settings.VsRootSuffix);
            await VsInstance.Prepare(hive, Settings.GetExtensionsToInstall(), Settings.VsResetSettings, diagnostics);

            instance = await VsInstance.Launch(hive, Settings.GetLaunchTimeout(), diagnostics);

            if (Debugger.IsAttached)
            {
                await VsInstance.AttachDebugger(instance.Process, Settings.VsDebugMixedMode, diagnostics);
            }
            instance.SetAssemblyResolver(TestAssemblyDirectory);
            rmt = instance.GetOrCreateSingletonService <Rmt>("VsixTesting.Xunit", Settings.VsSecureChannel);
            remoteTestAssemblyRunner = CreateRemoteTestAssemblyRunner(cts);
            initialized = true;
        }
        public async Task <RunSummary> RunAsync(CancellationTokenSource cts)
        {
            var remoteTestAssemblyRunner = default(RemoteTestAssemblyRunner);
            var runSummary = new RunSummary();

            try
            {
                await Init(cts);

                remoteTestAssemblyRunner = CreateRemoteTestAssemblyRunner(cts);
                runSummary = remoteTestAssemblyRunner.Run();
            }
            catch (Exception e)
            {
                runSummary = CalculateRunSummary();
                ReportRunningTestCases();
                await CancelRemainingTestCases(e, cts);

                throw;
            }
            finally
            {
                remoteTestAssemblyRunner?.Dispose();
            }

            return(runSummary);
        }
예제 #3
0
        public async Task Init(CancellationTokenSource cts)
        {
            if (initialized == true)
            {
                return;
            }

            AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;

            diagnostics = CreateDiagnostics(cts);
            if (testCases.OfType <VsTestCase>().GroupBy(c => c.Settings.SecureChannel).Count() >= 2)
            {
                throw new Exception($"All test methods sharing the same Visual Studio Instance must also use the same value for {nameof(ITestSettings.SecureChannel)}.");
            }
            var installation = Installations.Value.First(i => i.ApplicationPath == InstancePath);
            var hive         = new VsHive(installation, Settings.RootSuffix);
            await VsInstance.Prepare(hive, GetExtensionsToInstall(), Settings.ResetSettings, diagnostics);

            instance = await VsInstance.Launch(hive, Settings.GetLaunchTimeout(), diagnostics);

            if (Debugger.IsAttached)
            {
                await VsInstance.AttachDebugger(instance.Process, Settings.DebugMixedMode, diagnostics);
            }
            instance.SetAssemblyResolver(TestAssemblyDirectory);
            rmt = instance.GetOrCreateSingletonService <Rmt>("VsixTesting.Xunit", Settings.SecureChannel);
            remoteTestAssemblyRunner = CreateRemoteTestAssemblyRunner(cts);
            initialized = true;
        }