public void RunAllTestsInAssembly(string pathToAssembly, ISpecificationRunListener specificationRunListener) { Assembly assemblyToRun = Assembly.LoadFrom(pathToAssembly); DefaultRunner mspecRunner = new DefaultRunner(specificationRunListener, RunOptions.Default); mspecRunner.RunAssembly(assemblyToRun); }
public void RunTestsInAssembly(string pathToAssembly, IEnumerable<string> specsToRun, ISpecificationRunListener specificationRunListener) { try { Assembly assemblyToRun = Assembly.LoadFrom(pathToAssembly); DefaultRunner mspecRunner = new DefaultRunner(specificationRunListener, RunOptions.Default); foreach (string spec in specsToRun) { // get the spec type string[] splits = spec.Split(new string[] { "::" }, StringSplitOptions.RemoveEmptyEntries); string specClassName = splits[0]; string specFieldName = splits[1]; Type specType = assemblyToRun.GetType(specClassName); // get the method info from the type MemberInfo specField = specType.GetMembers(BindingFlags.Instance | BindingFlags.DeclaredOnly | BindingFlags.NonPublic | BindingFlags.Public).Where(x => x.Name == specFieldName).SingleOrDefault(); mspecRunner.RunMember(assemblyToRun, specField); } } catch (Exception) { throw; } }
public IEnumerable <Result> Run(Context context, ISpecificationRunListener listener, RunOptions options, IEnumerable <ICleanupAfterEveryContextInAssembly> globalCleanups, IEnumerable <ISupplementSpecificationResults> resultSupplementers) { IEnumerable <Result> results; listener.OnContextStart(context.GetInfo()); Result result = Result.Pass(); if (context.HasExecutableSpecifications) { result = context.EstablishContext(); } if (result.Passed) { results = RunSpecifications(context, listener, options, resultSupplementers); } else { results = FailSpecifications(context, listener, options, result, resultSupplementers); } if (context.HasExecutableSpecifications) { result = context.Cleanup(); foreach (var cleanup in globalCleanups) { cleanup.AfterContextCleanup(); } } listener.OnContextEnd(context.GetInfo()); return(results); }
public IEnumerable<Result> Run(Context context, ISpecificationRunListener listener, RunOptions options, IEnumerable<ICleanupAfterEveryContextInAssembly> globalCleanups, IEnumerable<ISupplementSpecificationResults> resultSupplementers) { IEnumerable<Result> results; listener.OnContextStart(context.GetInfo()); Result result = Result.Pass(); if (context.HasExecutableSpecifications) { result = context.EstablishContext(); } if (result.Passed) { results = RunSpecifications(context, listener, options, resultSupplementers); } else { results = FailSpecifications(context, listener, result, resultSupplementers); } if (context.HasExecutableSpecifications) { result = context.Cleanup(); foreach (var cleanup in globalCleanups) { cleanup.AfterContextCleanup(); } } listener.OnContextEnd(context.GetInfo()); return results; }
public IEnumerable<Result> Run(Context context, ISpecificationRunListener listener, RunOptions options) { IEnumerable<Result> results; listener.OnContextStart(context.GetInfo()); Result result = Result.Pass(); if (context.HasExecutableSpecifications) { result = context.EstablishContext(); } if (result.Passed) { results = RunSpecifications(context, listener, options); } else { results = FailSpecifications(context, listener, options, result); } if (context.HasExecutableSpecifications) { result = context.Cleanup(); } listener.OnContextEnd(context.GetInfo()); return results; }
static List <Result> FailSpecification(ISpecificationRunListener listener, Specification specification, Result result) { listener.OnSpecificationStart(specification.GetInfo()); listener.OnSpecificationEnd(specification.GetInfo(), result); return(new List <Result> { result }); }
public void RunAllTestsInAssembly(string pathToAssembly, ISpecificationRunListener specificationRunListener) { Assembly assemblyToRun = AssemblyHelper.Load(pathToAssembly); DefaultRunner mspecRunner = CreateRunner(assemblyToRun, specificationRunListener); mspecRunner.RunAssembly(assemblyToRun); }
public AppDomainRunner(ISpecificationRunListener listener, RunOptions options) { _listener = new RemoteRunListener(listener); _options = options; _signalRunStart = new InvokeOnce(listener.OnRunStart); _signalRunEnd = new InvokeOnce(listener.OnRunEnd); }
private DefaultRunner CreateRunner(Assembly assembly, ISpecificationRunListener specificationRunListener) { var listener = new AggregateRunListener(new[] { specificationRunListener, new AssemblyLocationAwareRunListener(new[] { assembly }) }); return(new DefaultRunner(listener, RunOptions.Default)); }
public SingleBehaviorTestRunListenerWrapper(ISpecificationRunListener runListener, VisualStudioTestIdentifier listenFor) { if (listenFor == null) throw new ArgumentNullException(nameof(listenFor)); if (runListener == null) throw new ArgumentNullException(nameof(runListener)); this.runListener = runListener; this.listenFor = listenFor; }
public DefaultRunner(ISpecificationRunListener listener, RunOptions options) { _listener = listener; _options = options; _assemblyRunner = new AssemblyRunner(_listener, _options); _explorer = new AssemblyExplorer(); _runStart = () => _listener.OnRunStart(); _runEnd = () => _listener.OnRunEnd(); }
public AssemblyRunner(ISpecificationRunListener listener, Assembly assembly, RunOptions options) { try { var runner = new DefaultRunner(listener, options); runner.RunAssembly(assembly); } catch (Exception err) { listener.OnFatalError(new ExceptionResult(err)); } }
private IEnumerable<Result> FailSpecifications(Context context, ISpecificationRunListener listener, RunOptions options, Result result) { var results = new List<Result>(); foreach (var specification in context.Specifications) { listener.OnSpecificationStart(specification.GetInfo()); listener.OnSpecificationEnd(specification.GetInfo(), result); results.Add(result); } return results; }
public NamespaceRunner(ISpecificationRunListener listener, Assembly assembly, RunOptions options, string targetNamespace) { try { var runner = new DefaultRunner(listener, options); runner.RunNamespace(assembly, targetNamespace); } catch (Exception err) { listener.OnFatalError(new ExceptionResult(err)); } }
public MemberRunner(ISpecificationRunListener listener, Assembly assembly, RunOptions options, MemberInfo memberInfo) { try { var runner = new DefaultRunner(listener, options); runner.RunMember(assembly, memberInfo); } catch (Exception err) { listener.OnFatalError(new ExceptionResult(err)); } }
public IEnumerable <Result> Run( Context context, ISpecificationRunListener listener, RunOptions options, IEnumerable <ICleanupAfterEveryContextInAssembly> globalCleanups, IEnumerable <ISupplementSpecificationResults> resultSupplementers) { var results = new List <Result>(); listener.OnContextStart(context.GetInfo()); foreach (var specification in context.Specifications) { var result = Result.Pass(); if (specification.IsExecutable) { result = context.EstablishContext(); } if (result.Passed) { var runner = new SpecificationRunner(listener, resultSupplementers); result = runner.Run(specification); } else { results = FailSpecification(listener, specification, result); } if (specification.IsExecutable) { var cleanupResult = context.Cleanup(); if (result.Passed && !cleanupResult.Passed) { result = cleanupResult; } foreach (var cleanup in globalCleanups) { cleanup.AfterContextCleanup(); } } results.Add(result); } listener.OnContextEnd(context.GetInfo()); return(results); }
public AssemblyRunner(ISpecificationRunListener listener, RunOptions options) { _listener = new AggregateRunListener(new[] { new AssemblyLocationAwareListener(), new AssemblyContextRunListener(), listener }); _options = options; _assemblyStart = OnAssemblyStart; _assemblyEnd = OnAssemblyEnd; }
private static IEnumerable<Result> RunSpecifications(Context context, ISpecificationRunListener listener, RunOptions options, IEnumerable<ISupplementSpecificationResults> resultSupplementers) { var results = new List<Result>(); foreach (var specification in context.Specifications) { var runner = new SpecificationRunner(listener, options, resultSupplementers); var result = runner.Run(specification); results.Add(result); } return results; }
public SingleBehaviorTestRunListenerWrapper(ISpecificationRunListener runListener, VisualStudioTestIdentifier listenFor) { if (listenFor == null) { throw new ArgumentNullException(nameof(listenFor)); } if (runListener == null) { throw new ArgumentNullException(nameof(runListener)); } this.runListener = runListener; this.listenFor = listenFor; }
public DefaultRunner(ISpecificationRunListener listener, RunOptions options, bool signalRunStartAndEnd) { _listener = listener; _options = options; _assemblyRunner = new AssemblyRunner(_listener, _options); _explorer = new AssemblyExplorer(); if (signalRunStartAndEnd) { _runStart = new InvokeOnce(() => _listener.OnRunStart()); _runEnd = new InvokeOnce(() => _listener.OnRunEnd()); } }
private static IEnumerable <Result> RunSpecifications(Context context, ISpecificationRunListener listener, RunOptions options, IEnumerable <ISupplementSpecificationResults> resultSupplementers) { var results = new List <Result>(); foreach (var specification in context.Specifications) { var runner = new SpecificationRunner(listener, options, resultSupplementers); var result = runner.Run(specification); results.Add(result); } return(results); }
public DefaultRunner(ISpecificationRunListener listener, RunOptions options, bool signalRunStartAndEnd) { this.listener = listener; this.options = options; assemblyRunner = new AssemblyRunner(this.listener, this.options); explorer = new AssemblyExplorer(); if (signalRunStartAndEnd) { runStart = new InvokeOnce(() => this.listener.OnRunStart()); runEnd = new InvokeOnce(() => this.listener.OnRunEnd()); } }
private static IEnumerable<Result> FailSpecifications(Context context, ISpecificationRunListener listener, Result result, IEnumerable<ISupplementSpecificationResults> resultSupplementers) { result = resultSupplementers.Aggregate(result, (r, supplement) => supplement.SupplementResult(r)); var results = new List<Result>(); foreach (var specification in context.Specifications) { listener.OnSpecificationStart(specification.GetInfo()); listener.OnSpecificationEnd(specification.GetInfo(), result); results.Add(result); } return results; }
public GallioRunListener(ISpecificationRunListener listener, IProgressMonitor progressMonitor, ITestContext context, IEnumerable <ITestCommand> specificationCommands) { _listener = listener; _progressMonitor = progressMonitor; _testContext = context; _outcome = TestOutcome.Passed; _contextsBySpec = new Dictionary <string, ITestContext>(); _commandsBySpec = (from command in specificationCommands let specificationTest = command.Test as MachineSpecificationTest where specificationTest != null select new { Name = specificationTest.Specification.Name, Command = command }) .ToDictionary(x => x.Name, x => x.Command); }
private static IEnumerable <Result> FailSpecifications(Context context, ISpecificationRunListener listener, RunOptions options, Result result, IEnumerable <ISupplementSpecificationResults> resultSupplementers) { result = resultSupplementers.Aggregate(result, (r, supplement) => supplement.SupplementResult(r)); var results = new List <Result>(); foreach (var specification in context.Specifications) { listener.OnSpecificationStart(specification.GetInfo()); listener.OnSpecificationEnd(specification.GetInfo(), result); results.Add(result); } return(results); }
public GallioRunListener(ISpecificationRunListener listener, IProgressMonitor progressMonitor, ITestContext context, IEnumerable<ITestCommand> specificationCommands) { _listener = listener; _progressMonitor = progressMonitor; _testContext = context; _outcome = TestOutcome.Passed; _contextsBySpec = new Dictionary<string, ITestContext>(); _commandsBySpec = (from command in specificationCommands let specificationTest = command.Test as MachineSpecificationTest where specificationTest != null select new { Name = specificationTest.Specification.Name, Command = command }) .ToDictionary(x => x.Name, x => x.Command); }
public AssemblyRunner(ISpecificationRunListener listener, RunOptions options) { var state = new RedirectOutputState(); _listener = new AggregateRunListener(new[] { new AssemblyLocationAwareListener(), new SetUpRedirectOutputRunListener(state), listener, new TearDownRedirectOutputRunListener(state), new AssemblyContextRunListener() }); _options = options; _assemblyStart = OnAssemblyStart; _assemblyEnd = OnAssemblyEnd; }
public AssemblyRunner(ISpecificationRunListener listener, RunOptions options) { var state = new RedirectOutputState(); this.options = options; this.listener = new AggregateRunListener(new[] { new AssemblyLocationAwareListener(), new SetUpRedirectOutputRunListener(state), listener, new TearDownRedirectOutputRunListener(state), }); assemblyStart = OnAssemblyStart; assemblyEnd = OnAssemblyEnd; }
public IEnumerable<Result> Run(Context context, ISpecificationRunListener listener, RunOptions options, IEnumerable<ICleanupAfterEveryContextInAssembly> globalCleanups, IEnumerable<ISupplementSpecificationResults> resultSupplementers) { var results = new List<Result>(); listener.OnContextStart(context.GetInfo()); foreach (var specification in context.Specifications) { Result result = Result.Pass(); if (specification.IsExecutable) { result = context.EstablishContext(); } if (result.Passed) { var runner = new SpecificationRunner(listener, options, resultSupplementers); result = runner.Run(specification); } else { results = FailSpecification(listener, specification, result); } if (specification.IsExecutable) { var cleanupResult = context.Cleanup(); if (result.Passed && !cleanupResult.Passed) { result = cleanupResult; } foreach (var cleanup in globalCleanups) { cleanup.AfterContextCleanup(); } } results.Add(result); } listener.OnContextEnd(context.GetInfo()); return results; }
public void RunTestsInAssembly(string pathToAssembly, IEnumerable<VisualStudioTestIdentifier> specsToRun, ISpecificationRunListener specificationRunListener) { DefaultRunner mspecRunner = null; Assembly assemblyToRun = null; try { assemblyToRun = Assembly.LoadFrom(pathToAssembly); mspecRunner = new DefaultRunner(specificationRunListener, RunOptions.Default); IEnumerable<Context> specificationContexts = new AssemblyExplorer().FindContextsIn(assemblyToRun) ?? Enumerable.Empty<Context>(); Dictionary<string, Context> contextMap = specificationContexts.ToDictionary(c => c.Type.FullName, StringComparer.Ordinal); // We use explicit assembly start and end to wrap the RunMember loop mspecRunner.StartRun(assemblyToRun); foreach (VisualStudioTestIdentifier test in specsToRun) { Context context = contextMap[test.ContainerTypeFullName]; if (context == null) continue; Specification specification = context.Specifications.SingleOrDefault(spec => spec.FieldInfo.Name.Equals(test.FieldName, StringComparison.Ordinal)); if (specification is BehaviorSpecification) { // MSpec doesn't expose any way to run an an "It" coming from a "[Behavior]", so we have to do some trickery VisualStudioTestIdentifier listenFor = specification.ToVisualStudioTestIdentifier(context); DefaultRunner behaviorRunner = new DefaultRunner(new SingleBehaviorTestRunListenerWrapper(specificationRunListener, listenFor), RunOptions.Default); behaviorRunner.RunMember(assemblyToRun, context.Type); } else { mspecRunner.RunMember(assemblyToRun, specification.FieldInfo); } } } catch (Exception e) { specificationRunListener.OnFatalError(new ExceptionResult(e)); } finally { if (mspecRunner != null && assemblyToRun != null) mspecRunner.EndRun(assemblyToRun); } }
public static void Run(this ISpecificationRunListener adapter, AssemblyInfo assemblyInfo, SpecificationInfo specificationInfo, Result failure, ExceptionResult exceptionResult, ContextInfo contexInfo) { adapter.OnAssemblyStart(assemblyInfo); adapter.OnAssemblyEnd(assemblyInfo); adapter.OnSpecificationStart(specificationInfo); adapter.OnSpecificationEnd(specificationInfo, failure); adapter.OnFatalError(exceptionResult); adapter.OnContextStart(contexInfo); adapter.OnContextEnd(contexInfo); adapter.OnRunStart(); adapter.OnRunEnd(); }
public AssemblyRunner(ISpecificationRunListener listener, RunOptions options) { RedirectOutputState state = new RedirectOutputState(); _listener = new AggregateRunListener(new[] { new AssemblyLocationAwareListener(), new SetUpRedirectOutputRunListener(state), listener, new TearDownRedirectOutputRunListener(state), }); _options = options; _explorer = new AssemblyExplorer(); _executedAssemblyContexts = new List <IAssemblyContext>(); _assemblyStart = OnAssemblyStart; _assemblyEnd = OnAssemblyEnd; }
public IEnumerable <Result> Run( Context context, ISpecificationRunListener listener, RunOptions options, IEnumerable <ICleanupAfterEveryContextInAssembly> globalCleanups, IEnumerable <ISupplementSpecificationResults> resultSupplementers) { listener.OnContextStart(context.GetInfo()); var result = Result.Pass(); if (context.HasExecutableSpecifications) { result = context.EstablishContext(); } var results = result.Passed ? RunSpecifications(context, listener, options, resultSupplementers) : FailSpecifications(context, listener, result, resultSupplementers); if (context.HasExecutableSpecifications) { var cleanupResult = context.Cleanup(); if (!cleanupResult.Passed) { listener.OnFatalError(cleanupResult.Exception); } foreach (var cleanup in globalCleanups) { cleanup.AfterContextCleanup(); } } listener.OnContextEnd(context.GetInfo()); return(results); }
public IEnumerable<Result> Run(Context context, ISpecificationRunListener listener, RunOptions options) { var results = new List<Result>(); listener.OnContextStart(context.GetInfo()); foreach (var specification in context.Specifications) { Result result = Result.Pass(); if (specification.IsExecutable) { result = context.EstablishContext(); } if (result.Passed) { var runner = new SpecificationRunner(listener, options); result = runner.Run(specification); } if (specification.IsExecutable) { var cleanupResult = context.Cleanup(); if (result.Passed && !cleanupResult.Passed) { result = cleanupResult; } } results.Add(result); } listener.OnContextEnd(context.GetInfo()); return results; }
public ReflectionRunListener(ISpecificationRunListener listener) { this.listener = listener; }
public AppDomainRunner(ISpecificationRunListener listener, RunOptions options) { _internalListener = listener; _listener = new RemoteRunListener(listener); _options = options; }
public DefaultRunner(ISpecificationRunListener listener, RunOptions options) : this(listener, options, true) { }
void SetupListeners(TestExecutionOptions options) { _listener = new AggregateRunListener(Enumerable.Empty <ISpecificationRunListener>()); }
private Controller(Action <string> listenCallback, RunOptions runOptions) { listener = new ControllerRunListener(listenCallback); explorer = new AssemblyExplorer(); runner = new DefaultRunner(listener, runOptions, false); }
public WcfRunnerProxy(ISpecificationRunListener listener) { _listener = listener; }
public SpecificationRunner(ISpecificationRunListener listener, RunOptions options) { _listener = listener; _options = options; }
public void RunTestsInAssembly(string pathToAssembly, IEnumerable <VisualStudioTestIdentifier> specsToRun, ISpecificationRunListener specificationRunListener) { DefaultRunner mspecRunner = null; Assembly assemblyToRun = null; try { assemblyToRun = AssemblyHelper.Load(pathToAssembly); mspecRunner = CreateRunner(assemblyToRun, specificationRunListener); IEnumerable <Context> specificationContexts = new AssemblyExplorer().FindContextsIn(assemblyToRun) ?? Enumerable.Empty <Context>(); Dictionary <string, Context> contextMap = specificationContexts.ToDictionary(c => c.Type.FullName, StringComparer.Ordinal); // We use explicit assembly start and end to wrap the RunMember loop mspecRunner.StartRun(assemblyToRun); foreach (VisualStudioTestIdentifier test in specsToRun) { Context context = contextMap[test.ContainerTypeFullName]; if (context == null) { continue; } Specification specification = context.Specifications.SingleOrDefault(spec => spec.FieldInfo.Name.Equals(test.FieldName, StringComparison.Ordinal)); if (specification is BehaviorSpecification) { // MSpec doesn't expose any way to run an an "It" coming from a "[Behavior]", so we have to do some trickery VisualStudioTestIdentifier listenFor = specification.ToVisualStudioTestIdentifier(context); DefaultRunner behaviorRunner = new DefaultRunner(new SingleBehaviorTestRunListenerWrapper(specificationRunListener, listenFor), RunOptions.Default); behaviorRunner.RunMember(assemblyToRun, context.Type.GetTypeInfo()); } else { mspecRunner.RunMember(assemblyToRun, specification.FieldInfo); } } } catch (Exception e) { specificationRunListener.OnFatalError(new ExceptionResult(e)); } finally { if (mspecRunner != null && assemblyToRun != null) { mspecRunner.EndRun(assemblyToRun); } } }
public SpecificationRunner(ISpecificationRunListener listener, RunOptions options, IEnumerable <ISupplementSpecificationResults> resultSupplementers) { _listener = listener; _options = options; _resultSupplementers = resultSupplementers; }
public SpecificationRunner(ISpecificationRunListener listener, RunOptions options, IEnumerable<ISupplementSpecificationResults> resultSupplementers) { _listener = listener; _options = options; _resultSupplementers = resultSupplementers; }
static List<Result> FailSpecification(ISpecificationRunListener listener, Specification specification, Result result) { listener.OnSpecificationStart(specification.GetInfo()); listener.OnSpecificationEnd(specification.GetInfo(), result); return new List<Result> { result }; }
public RemoteRunListener(ISpecificationRunListener listener) { _listener = listener; }
private Controller(Action<string> listenCallback, RunOptions runOptions) { _listener = new ControllerRunListener(listenCallback); _explorer = new AssemblyExplorer(); _runner = new DefaultRunner(_listener, runOptions, signalRunStartAndEnd: false); }
public NamespaceRunner(ISpecificationRunListener listener, Assembly assembly, RunOptions options, string targetNamespace) { var runner = new DefaultRunner(listener, options); runner.RunNamespace(assembly, targetNamespace); }
void SetupListeners(TestExecutionOptions options) { _listener = new AggregateRunListener(Enumerable.Empty<ISpecificationRunListener>()); }
public DefaultRunner(ISpecificationRunListener listener, RunOptions options) { _listener = listener; _options = options; _explorer = new AssemblyExplorer(); }