private IRunner CreateTextRunner(IEnumerable <string> assemblies, IEventListener listener, string scenarioText) { var configuration = NBehaveConfiguration.New .SetAssemblies(assemblies) .SetEventListener(listener); if (!String.IsNullOrEmpty(scenarioText)) { // Configure the scenario to get run tempFileName = Path.GetTempFileName(); using (var fileStream = new StreamWriter(File.Create(tempFileName))) { fileStream.Write(scenarioText); } configuration.SetScenarioFiles(new[] { tempFileName }); } return(RunnerFactory.CreateTextRunner(configuration)); }
public override bool Execute() { if (TestAssemblies.Length == 0) { throw new ArgumentException("At least one test assembly is required"); } var logString = new StringBuilder(); TextWriter msbuildLogWriter = new StringWriter(logString); var output = new PlainTextOutput(msbuildLogWriter); WriteHeaderInto(output); var config = NBehaveConfiguration.New .DontIsolateInAppDomain() .SetScenarioFiles(ScenarioFiles) .SetDryRun(DryRun) .SetAssemblies(TestAssemblies) .SetEventListener(EventListeners.CreateEventListenerUsing(msbuildLogWriter, TextOutputFile, XmlOutputFile)); var runner = RunnerFactory.CreateTextRunner(config); FeatureResults = runner.Run(); if (DryRun) { return(true); } var message = logString.ToString(); Log.LogMessage(message); if (FailBuild && FailBuildBasedOn(FeatureResults)) { return(false); } return(true); }
public static IRunner Build(this NBehaveConfiguration configuration) { return(RunnerFactory.CreateTextRunner(configuration)); }