public void DiscoverTests(IEnumerable<string> sources, IDiscoveryContext discoveryContext, IMessageLogger log, ITestCaseDiscoverySink discoverySink) { log.Version(); RemotingUtility.CleanUpRegisteredChannels(); foreach (var assemblyPath in sources) { try { if (AssemblyDirectoryContainsFixie(assemblyPath)) { log.Info("Processing " + assemblyPath); using (var environment = new ExecutionEnvironment(assemblyPath)) { var methodGroups = environment.DiscoverTestMethodGroups(new Options()); foreach (var methodGroup in methodGroups) discoverySink.SendTestCase(new TestCase(methodGroup.FullName, VsTestExecutor.Uri, assemblyPath)); } } else { log.Info("Skipping " + assemblyPath + " because it is not a test assembly."); } } catch (Exception exception) { log.Error(exception); } } }
/// <summary> /// Called by Visual Studio, when running all tests. /// Called by TFS Build, when running all tests. /// Called by TFS Build, with a filter within the run context, when running selected tests. /// </summary> /// <param name="sources"></param> /// <param name="runContext"></param> /// <param name="frameworkHandle"></param> public void RunTests(IEnumerable <string> sources, IRunContext runContext, IFrameworkHandle frameworkHandle) { IMessageLogger log = frameworkHandle; log.Version(); HandlePoorVisualStudioImplementationDetails(runContext, frameworkHandle); var runAllTests = new PipeMessage.ExecuteTests { Filter = new PipeMessage.Test[] { } }; foreach (var assemblyPath in sources) { RunTests(log, frameworkHandle, assemblyPath, pipe => pipe.Send(runAllTests)); } }
public void DiscoverTests(IEnumerable <string> sources, IDiscoveryContext discoveryContext, IMessageLogger log, ITestCaseDiscoverySink discoverySink) { log.Version(); RemotingUtility.CleanUpRegisteredChannels(); foreach (var assemblyPath in sources) { try { if (AssemblyDirectoryContainsFixie(assemblyPath)) { log.Info("Processing " + assemblyPath); ISourceLocationProvider sourceLocationProvider = new SourceLocationProvider(); using (var environment = new ExecutionEnvironment(assemblyPath)) { var methodGroups = environment.DiscoverTestMethodGroups(new Options()); //Debugger.Launch(); foreach (var methodGroup in methodGroups) { var testCase = new TestCase(methodGroup.FullName, VsTestExecutor.Uri, assemblyPath); var sourceLocation = sourceLocationProvider.GetSourceLocation(assemblyPath, methodGroup.Class, methodGroup.Method); testCase.CodeFilePath = sourceLocation.Path; testCase.LineNumber = sourceLocation.LineNumber; discoverySink.SendTestCase(testCase); } } } else { log.Info("Skipping " + assemblyPath + " because it is not a test assembly."); } } catch (Exception exception) { log.Error(exception); } } }
/// <summary> /// Called by the IDE, when running selected tests. /// Never called from Azure DevOps. /// </summary> /// <param name="tests"></param> /// <param name="runContext"></param> /// <param name="frameworkHandle"></param> public void RunTests(IEnumerable <TestCase> tests, IRunContext runContext, IFrameworkHandle frameworkHandle) { try { IMessageLogger log = frameworkHandle; log.Version(); HandlePoorVsTestImplementationDetails(runContext, frameworkHandle); var assemblyGroups = tests.GroupBy(tc => tc.Source); foreach (var assemblyGroup in assemblyGroups) { var assemblyPath = assemblyGroup.Key; RunTests(log, frameworkHandle, assemblyPath, pipe => { pipe.Send(new PipeMessage.ExecuteTests { Filter = assemblyGroup.Select(x => { var test = new Test(x.FullyQualifiedName); return(new PipeMessage.Test { Class = test.Class, Method = test.Method, Name = test.Name }); }).ToArray() }); }); } } catch (Exception exception) { throw new RunnerException(exception); } }
public void RunTests(IEnumerable <TestCase> tests, IRunContext runContext, IFrameworkHandle frameworkHandle) { IMessageLogger log = frameworkHandle; log.Version(); HandlePoorVisualStudioImplementationDetails(runContext, frameworkHandle); var assemblyGroups = tests.GroupBy(tc => tc.Source); foreach (var assemblyGroup in assemblyGroups) { var assemblyPath = assemblyGroup.Key; try { if (AssemblyDirectoryContainsFixie(assemblyPath)) { log.Info("Processing " + assemblyPath); var methodGroups = assemblyGroup.Select(x => new MethodGroup(x.FullyQualifiedName)).ToArray(); var listener = new VisualStudioListener(frameworkHandle, assemblyPath); using (var environment = new ExecutionEnvironment(assemblyPath)) { environment.RunMethods(new Options(), listener, methodGroups); } } else { log.Info("Skipping " + assemblyPath + " because it is not a test assembly."); } } catch (Exception exception) { log.Error(exception); } } }