void RunSpecificationAssembly(string fileName, ISpecificationRunner runner) { Ensure.ArgumentIsNotNullOrEmptyString(fileName, "fileName"); try { string originalWorkingDirectory = Environment.CurrentDirectory; try { Environment.CurrentDirectory = WorkingDirectory.FullName; Log(Level.Info, "Loading assembly {0}", fileName); Assembly assembly = Assembly.LoadFrom(fileName); runner.RunAssembly(assembly); } finally { Environment.CurrentDirectory = originalWorkingDirectory; } } catch (Exception ex) { throw new BuildException("Unexpected error while running specs", ex); } }
public override TaskResult Start(TaskExecutionNode node) { var task = (RunAssemblyTask)node.RemoteTask; _contextAssembly = LoadContextAssembly(task); if (_contextAssembly == null) { return(TaskResult.Error); } var result = VersionCompatibilityChecker.Check(_contextAssembly); if (!result.Success) { Server.TaskExplain(task, result.Explanation); Server.TaskError(task, result.ErrorMessage); return(TaskResult.Error); } _listener = new PerAssemblyRunListener(Server, task); _runner = new DefaultRunner(_listener, RunOptions.Default); _runScope = GetRunScope(_runner); return(TaskResult.Success); }
public void BeforeEach() { command = new DefaultSpecificationRunner(new DefaultExpressionRunnerFactory().CreateExpressionRunner(false), new DefaultSpecificationFinder(new DefaultFileSystem()), new SilentConsoleFormatter(new DefaultConsoleWritter())); path = new Uri(Assembly.GetAssembly(typeof(TestSpecificationWithBeforeAll)).CodeBase).LocalPath; }
public override TaskResult Start(TaskExecutionNode node) { var task = (RunAssemblyTask) node.RemoteTask; _contextAssembly = LoadContextAssembly(task); if (_contextAssembly == null) { return TaskResult.Error; } var result = VersionCompatibilityChecker.Check(_contextAssembly); if (!result.Success) { Server.TaskExplain(task, result.Explanation); Server.TaskError(task, result.ErrorMessage); return TaskResult.Error; } _listener = new PerAssemblyRunListener(Server, task); _runner = new DefaultRunner(_listener, RunOptions.Default, false); return TaskResult.Success; }
void RunSpecifications(FileSet[] assemblies, ISpecificationRunner runner) { Ensure.ArgumentIsNotNull(assemblies, "assemblies"); Ensure.ArgumentIsNotNull(runner, "runner"); foreach (string fileName in FileSetHelper.Flatten(assemblies)) { RunSpecificationAssembly(fileName, runner); } }
void RunContext(ISpecificationRunner runner, Assembly contextAssembly, TaskExecutionNode node) { var task = (ContextTask) node.RemoteTask; var contextClass = contextAssembly.GetType(task.ContextTypeName); if (contextClass == null) { Server.TaskOutput(task, String.Format("Could not load type '{0}' from assembly {1}.", task.ContextTypeName, task.AssemblyLocation), TaskOutputType.STDOUT); Server.TaskException(node.RemoteTask, new[] {new TaskException(new Exception("Could not load context"))}); return; } runner.RunMember(contextAssembly, contextClass); }
void RunContext(ISpecificationRunner runner, Assembly contextAssembly, TaskExecutionNode node) { var task = (ContextTask)node.RemoteTask; var contextClass = contextAssembly.GetType(task.ContextTypeName); if (contextClass == null) { Server.TaskOutput(task, String.Format("Could not load type '{0}' from assembly {1}.", task.ContextTypeName, task.AssemblyLocation), TaskOutputType.STDOUT); Server.TaskException(node.RemoteTask, new[] { new TaskException(new Exception("Could not load context")) }); return; } runner.RunMember(contextAssembly, contextClass); }
static RunScope GetRunScope(ISpecificationRunner runner) { var scope = new RunScope(); var runnerType = runner.GetType(); var startRun = runnerType.GetMethod("StartRun", new[] { typeof(Assembly) }); if (startRun != null) { scope.StartRun = asm => startRun.Invoke(runner, new object[] { asm }); } var endRun = runnerType.GetMethod("EndRun", new[] { typeof(Assembly) }); if (endRun != null) { scope.EndRun = asm => endRun.Invoke(runner, new object[] { asm }); } return(scope); }
public void BeforeAll() { var finder = new DefaultSpecificationFinder(new DefaultFileSystem()); var expressionRunner = new DefaultExpressionRunnerFactory().CreateExpressionRunner(false); var formatter = new SilentConsoleFormatter(new DefaultConsoleWritter()); runner = new DefaultSpecificationRunner(expressionRunner, finder, formatter); var location = new Uri(typeof(TestSpecificationConfigurationManager).Assembly.CodeBase).LocalPath; var appDomain = new SpecificationAppDomain(runner); var results = appDomain.ExecuteSpecifications(location); using (var stream = new MemoryStream()) { var reporter = new NUnitSpecificationReporter(); reporter.Write(stream, results); stream.Seek(0, SeekOrigin.Begin); var serializer = new XmlSerializer(typeof(resultType)); using (var reader = XmlReader.Create(stream)) { resultType = (resultType)serializer.Deserialize(reader); } } }
public SpecificationAppDomain(ISpecificationRunner runner) { this.runner = runner; }
public DefaultTestExecutor(ISpecificationRunner runner) { appDomainRunner = new SpecificationAppDomain(runner); }
public SpecificationAssembly(ISpecificationRunner runner) { this.runner = runner; }
public SpecificationsExecutor(ISpecificationManager specificationManager, ISpecificationRunner runner) { _specificationManager = specificationManager; _runner = runner; }
public DefaultTestDiscoverer(ISpecificationRunner runner) { appDomainRunner = new SpecificationAppDomain(runner); }