public void Write(ILiveFormatter formatter) { if (example.HasRun) { context.WriteAncestors(formatter); formatter.Write(example, context.Level); } }
/// <summary> /// Test execution happens in two phases: this is the first phase. /// </summary> /// <remarks> /// Here all contexts and all their examples are run, collecting distinct exceptions /// from context itself (befores/ acts/ it/ afters), beforeAll, afterAll. /// </remarks> public virtual void Run(ILiveFormatter formatter, bool failFast, nspec instance = null, bool recurse = true) { if (failFast && Parent.HasAnyFailures()) { return; } var nspec = savedInstance ?? instance; bool runBeforeAfterAll = AnyUnfilteredExampleInSubTree(nspec); using (new ConsoleCatcher(output => this.CapturedOutput = output)) { if (runBeforeAfterAll) { RunAndHandleException(RunBeforeAll, nspec, ref ExceptionBeforeAll); } } // intentionally using for loop to prevent collection was modified error in sample specs for (int i = 0; i < Examples.Count; i++) { var example = Examples[i]; if (failFast && example.Context.HasAnyFailures()) { return; } using (new ConsoleCatcher(output => example.CapturedOutput = output)) { Exercise(example, nspec); } if (example.HasRun && !alreadyWritten) { WriteAncestors(formatter); alreadyWritten = true; } if (example.HasRun) { formatter.Write(example, Level); } } if (recurse) { Contexts.Do(c => c.Run(formatter, failFast, nspec)); } if (runBeforeAfterAll) { RunAndHandleException(RunAfterAll, nspec, ref ExceptionAfterAll); } }
void WriteAncestors(ILiveFormatter formatter) { if (Parent == null) { return; } Parent.WriteAncestors(formatter); if (!alreadyWritten) { formatter.Write(this); } alreadyWritten = true; }
public virtual void Run(ILiveFormatter formatter, bool failFast, nspec instance = null) { if (failFast && Parent.HasAnyFailures()) { return; } var nspec = savedInstance ?? instance; if (AllExamples().Count() > 0) { RunAndHandleException(RunBeforeAll, nspec, ref Exception); } //intentionally using for loop to prevent collection was modified error in sample specs for (int i = 0; i < Examples.Count; i++) { var example = Examples[i]; if (failFast && example.Context.HasAnyFailures()) { return; } Exercise(example, nspec); if (example.HasRun && !alreadyWritten) { WriteAncestors(formatter); alreadyWritten = true; } if (example.HasRun) { formatter.Write(example, Level); } } Contexts.Do(c => c.Run(formatter, failFast, nspec)); if (AllExamples().Count() > 0) { RunAndHandleException(RunAfterAll, nspec, ref Exception); } }
public void WriteAncestors(ILiveFormatter formatter) { if (alreadyWritten) { return; } // when hitting root `nspec` context, skip it if (Parent == null) { alreadyWritten = true; return; } Parent.WriteAncestors(formatter); formatter.Write(this); alreadyWritten = true; }
void WriteAncestors(ILiveFormatter formatter) { if (Parent == null) return; Parent.WriteAncestors(formatter); if (!alreadyWritten) formatter.Write(this); alreadyWritten = true; }
public virtual void Run(ILiveFormatter formatter, bool failFast, nspec instance = null) { if (failFast && Parent.HasAnyFailures()) return; var nspec = savedInstance ?? instance; if(AllExamples().Any(e=>e.ShouldNotSkip(nspec.tagsFilter))) RunAndHandleException(RunBeforeAll, nspec, ref Exception); //intentionally using for loop to prevent collection was modified error in sample specs for (int i = 0; i < Examples.Count; i++) { var example = Examples[i]; if (failFast && example.Context.HasAnyFailures()) return; Exercise(example, nspec); if (example.HasRun && !alreadyWritten) { WriteAncestors(formatter); alreadyWritten = true; } if (example.HasRun) formatter.Write(example, Level); } Contexts.Do(c => c.Run(formatter, failFast, nspec)); if (AllExamples().Count() > 0) RunAndHandleException(RunAfterAll, nspec, ref Exception); }
public virtual void Run(ILiveFormatter formatter, bool failFast, nspec instance = null) { if (failFast && Parent.HasAnyFailures()) return; var nspec = savedInstance ?? instance; for (int i = 0; i < Examples.Count; i++) { var example = Examples[i]; if (failFast && example.Context.HasAnyFailures()) return; Exercise(example, nspec); if (example.HasRun && !alreadyWritten) { WriteAncestors(formatter); alreadyWritten = true; } if (example.HasRun) formatter.Write(example, Level); } Contexts.Do(c => c.Run(formatter, failFast, nspec)); }
public virtual void Run(ILiveFormatter formatter, bool failFast, nspec instance = null) { if (failFast && Parent.HasAnyFailures()) return; var nspec = savedInstance ?? instance; if(AllExamples().Any(e=>e.ShouldNotSkip(nspec.tagsFilter))) RunAndHandleException(RunBeforeAll, nspec, ref Exception); //intentionally using for loop to prevent collection was modified error in sample specs for (int i = 0; i < Examples.Count; i++) { var example = Examples[i]; if (failFast && example.Context.HasAnyFailures()) return; Exercise(example, nspec); if (example.HasRun && !alreadyWritten) { WriteAncestors(formatter); alreadyWritten = true; } if (example.HasRun) formatter.Write(example, Level); } //allow Contexts to change dynamically during the test List<Context> runContexts = new List<Context>(); List<Context> contexts = new List<Context>(Contexts); while (contexts.Count()>0) { contexts.Do(c => c.Run(formatter, failFast, nspec)); runContexts.AddRange(contexts); contexts = new List<Context>(Contexts.Where(p => !runContexts.Contains(p))); } if (AllExamples().Count() > 0) RunAndHandleException(RunAfterAll, nspec, ref Exception); }