public void Run(TestContext context) { var environment = new TestEnvironment(context.AssemblyTask); var listener = new TestRunListener(_taskServer, context); var runOptions = RunOptions.Custom.FilterBy(context.GetContextNames()); if (environment.ShouldShadowCopy) { runOptions.ShadowCopyTo(environment.ShadowCopyPath); _taskServer.SetTempFolderPath(environment.ShadowCopyPath); } var appDomainRunner = new AppDomainRunner(listener, runOptions); try { appDomainRunner.RunAssembly(new AssemblyPath(environment.AssemblyPath)); } catch (Exception e) { _taskServer.ShowNotification("Unable to run tests: " + e.Message, string.Empty); _taskServer.TaskException(context.AssemblyTask, new[] { new TaskException(e) }); } }
public void Execute() { var assembly = request.Container.Location; var testsToRun = context.GetTestsToRun().ToArray(); var contexts = testsToRun .Select(x => x.Context.TypeName) .Distinct(); var cache = new ElementCache(testsToRun); var tracker = new RunTracker(testsToRun); var listener = new TestExecutionListener(context, cache, token); var adapter = new ExecutionAdapterRunListener(listener, cache, tracker); var loggingListener = new LoggingRunListener(adapter); var machineAdapter = new AdapterListener(loggingListener, assembly); var runOptions = RunOptions.Custom.FilterBy(contexts); var runner = new AppDomainRunner(machineAdapter, runOptions); runner.RunAssembly(new AssemblyPath(request.Container.Location)); listener.Finished.WaitOne(); }
public TestRunState RunAssembly(ITestListener testListener, Assembly assembly) { var listener = new TDNetRunListener(testListener); var runner = new AppDomainRunner(listener, RunOptions.Default); runner.RunAssembly(assembly); return(listener.TestRunState); }
private void runTests(RunSettings settings, Assembly assembly, AppDomainRunner runner) { if (runAllTests(settings)) { runner.RunAssembly(assembly); return; } foreach (var member in settings.Assembly.Tests) runner.RunMember(assembly, assembly.GetType(member)); foreach (var member in settings.Assembly.Members) runner.RunMember(assembly, assembly.GetType(member)); foreach (var ns in settings.Assembly.Namespaces) runner.RunNamespace(assembly, ns); }
private static ExitCode RunAssembly(Assembly assembly, RunOptions runOptions) { ISpecificationRunListener listener = new BufferedAssemblyTeamCityReporter(WriteToTeamCity); ISpecificationRunner specificationRunner = new AppDomainRunner(listener, runOptions); specificationRunner.RunAssembly(assembly); if (listener is ISpecificationResultProvider) { var errorProvider = (ISpecificationResultProvider)listener; if (errorProvider.FailureOccurred) { return(ExitCode.Failure); } } return(ExitCode.Success); }
public override void ExecuteRecursive(TaskExecutionNode node) { var task = (RunAssemblyTask)node.RemoteTask; var priorCurrentDirectory = Environment.CurrentDirectory; try { // Use the assembly in the folder that the user has specified, or, if not, use the assembly location var assemblyFolder = GetAssemblyFolder(TaskExecutor.Configuration, task); var assemblyPath = new AssemblyPath(Path.Combine(assemblyFolder, GetFileName(task.AssemblyLocation))); Environment.CurrentDirectory = assemblyFolder; var listener = new PerAssemblyRunListener(Server, task); var contextList = new List <string>(); node.Flatten(x => x.Children).Each(children => RegisterRemoteTaskNotifications(listener, children, contextList)); var runOptions = RunOptions.Custom.FilterBy(contextList); var appDomainRunner = new AppDomainRunner(listener, runOptions); if (TaskExecutor.Configuration.ShadowCopy) { string cachePath = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); runOptions.ShadowCopyTo(cachePath); this.Server.SetTempFolderPath(cachePath); } appDomainRunner.RunAssembly(assemblyPath); } finally { Environment.CurrentDirectory = priorCurrentDirectory; } }