} // constructor public void SetResult(StepResults stepResult, string outcum) { this.endTime = DateTime.UtcNow; this.executed = true; this.result = stepResult; this.outcome = outcum; } // SetResult
public virtual void Dump() { Console.WriteLine("Result: {0}", Success); Console.WriteLine("Duration: {0}ms", Duration.TotalMilliseconds); Console.WriteLine("Step Results:"); StepResults.ForEach(s => Console.WriteLine("\t{0}", s)); }
void Ex02() { Given("GivenStep that has an arrangement that does not throw any exceptions", () => Step = FixtureSteps.CreateGivenStep(() => { })); Given("a result of ThenStep", () => StepResults.Add(FixtureStepResult.Of(FixtureSteps.CreateThenStep()).Passed().Build())); When("the given GivenStep is run", () => Result = RunnerOf(Step).Run(StepResults).Build()); Then("InvalidFixtureStepException should be thrown", exc => exc.GetType() == typeof(InvalidFixtureStepException)); }
public void WriteResults(StepResults results, ITestContext context) { if (!_cell.IsResult) { WritePreview(context); return; } var actual = results.HasActual(_cell.Key) ? results.GetActual(_cell.Key) : "MISSING"; if (results.IsInException(_cell.Key)) { Text("Error!"); AddClass(HtmlClasses.EXCEPTION); return; } if (results.IsFailure(_cell.Key)) { var expected = _step.Get(_cell.Key); string text = "{0}, but was '{1}'".ToFormat(expected, actual); Text(text); AddClass(HtmlClasses.FAIL); } else { Text(context.GetDisplay(actual)); AddClass(HtmlClasses.PASS); } }
public override StepResults Execute() { try { Log.Debug("Start of step {0} for {1}...", Name, OuterContextDescription); StepResults nextStep = Run(); Log.Debug( "End of step {0} with result {1} for {2}.", Name, Outcome, OuterContextDescription ); CollectOutputValues(); return(nextStep); } catch (Exception e) { Log.Alert( e, "Exception during step {0} while executing for {1}.", Name, OuterContextDescription ); return(StepResults.AbnormalShutdown); } // try } // Execute
void Ex03() { var thenStepCompleted = false; Given("async ThenStep that has an assertion with Exception that does not throw any exceptions", () => { Step = FixtureSteps.CreateThenStep <ArgumentNullException>(async _ => { await Task.Delay(100); thenStepCompleted = true; }); ExpectedResult = FixtureStepResultAssertion.ForNullException(FixtureStepStatus.Passed, Step); }); Given("async next ThenStep that asserts the Exception that is thrown at WhenStep", () => { NextStep = FixtureSteps.CreateThenStep <ArgumentNullException>(async _ => { await Task.Delay(100); thenStepCompleted = true; }); ExpectedNextResult = FixtureStepResultAssertion.ForNullException(FixtureStepStatus.Passed, NextStep); }); When("the given ThenStep is run", () => { Result = RunnerOf(Step).Run(StepResults).Build(); StepResults.Add(Result); }); Then("the given ThenStep should be awaited", () => thenStepCompleted); Then($"the result should be as follows:{ExpectedResult.ToDescription()}", () => FixtureStepResultAssertion.Of(Result) == ExpectedResult); thenStepCompleted = false; When("the given next ThenStep is run", () => Result = RunnerOf(NextStep).Run(StepResults).Build()); Then("the given next ThenStep should be awaited", () => thenStepCompleted); Then($"the result should be as follows:{ExpectedNextResult.ToDescription()}", () => FixtureStepResultAssertion.Of(Result) == ExpectedNextResult); }
public Results(SentenceTag tag, ITestContext context) { _tag = tag; _context = context; _results = _context.ResultsFor(tag._step); _step = tag._step; }
public void capture_exception_text() { var errors = new StepResults(); errors.CaptureException(new NotImplementedException().ToString()); errors.ExceptionText.ShouldContain("NotImplementedException"); }
public void capturing_an_exception_means_that_has_errors_should_be_true() { var errors = new StepResults(); errors.HasErrors().ShouldBeFalse(); errors.CaptureException(new NotImplementedException().ToString()); errors.HasErrors().ShouldBeTrue(); }
public void mark_as_failure() { var errors = new StepResults(); errors.MarkFailure("key1"); errors.IsFailure("key1").ShouldBeTrue(); errors.IsFailure("key2").ShouldBeFalse(); }
void ITestStream.StartParagraph(Paragraph paragraph, IStep step) { _paragraphResults = _context.ResultsFor(step); _paragraphResults.MoveFirst(); var tag = new ParagraphTag(paragraph, step); _document.Push(tag); }
public void store_and_retrieve_a_result() { var result = new List<SetRow>(); var results = new StepResults(); results.SetResult(result, "key"); results.GetResult<List<SetRow>>("key").ShouldBeTheSameAs(result); }
void Ex10() { Given("ThenStep that has an assertion with Exception that returns boolean", () => Step = FixtureSteps.CreateThenStep(new Action <Exception>(exc => throw new Exception()))); Given("a result of GivenStep that does not have an exception", () => StepResults.Add(FixtureStepResult.Of(FixtureSteps.CreateGivenStep()).Passed().Build())); Given("a result of WhenStep that has an exception", () => StepResults.Add(FixtureStepResult.Of(FixtureSteps.CreateWhenStep()).Failed(new Exception()).Build())); When("the given ThenStep is run", () => RunnerOf(Step).Run(StepResults).Build()); Then("the status of the result of the latest WhenStep should be Passed", () => StepResults.GetLatestStepResultsOf <WhenStep>().First().Status == FixtureStepStatus.Passed); Then("the exception of the result of the latest WhenStep should be null", () => StepResults.GetLatestStepResultsOf <WhenStep>().First().Exception == null); }
public void marking_a_missing_value_should_set_HasErrors_to_true() { var errors = new StepResults(); errors.HasErrors().ShouldBeFalse(); errors.MarkMissingValue("a"); errors.HasErrors().ShouldBeTrue(); }
public void store_and_retrieve_a_result() { var result = new List <SetRow>(); var results = new StepResults(); results.SetResult(result, "key"); results.GetResult <List <SetRow> >("key").ShouldBeTheSameAs(result); }
public void capture_exception_with_frame() { var errors = new StepResults(); errors.CaptureException("anything"); errors.MoveFrame(); errors.HasErrors().ShouldBeFalse(); errors.ExceptionText.ShouldBeEmpty(); }
public void reset_clears_failure_keys() { var errors = new StepResults(); errors.MarkFailure("key1"); errors.Clear(); errors.IsInException("key1").ShouldBeFalse(); }
public void MarkMissingStep() { var errors = new StepResults(); errors.MarkMissingValue("a"); errors.ExceptionText.ShouldEqual("\"a\" is not defined."); errors.MarkMissingValue("b"); errors.ExceptionText.ShouldEqual("\"a\" is not defined.\n\"b\" is not defined."); }
public void mark_as_exception() { var errors = new StepResults(); errors.MarkFormatFailure("key1"); errors.MarkMissingValue("key2"); errors.IsInException("key1").ShouldBeTrue(); errors.IsInException("key2").ShouldBeTrue(); errors.IsInException("key3").ShouldBeFalse(); }
void Ex03() { Given("GivenStep that has an arrangement that does not throw any exceptions", () => { Step = FixtureSteps.CreateGivenStep(() => { }); ExpectedResult = FixtureStepResultAssertion.ForNullException(FixtureStepStatus.Ready, Step); }); Given("a result of GivenStep that has an exception", () => StepResults.Add(FixtureStepResult.Of(FixtureSteps.CreateGivenStep()).Failed(new Exception()).Build())); When("the given GivenStep is run", () => Result = RunnerOf(Step).Run(StepResults).Build()); Then($"the result should be as follows:{ExpectedResult.ToDescription()}", () => FixtureStepResultAssertion.Of(Result) == ExpectedResult); }
public void AddStepResult(Step step) { if (!StepResults.Any(sr => sr.Step.SelectorId == step.SelectorId && sr.Step.Value == step.Value)) { StepResults.Add(new StepResult(step)); } else { var stepResult = StepResults.First(sr => sr.Step.SelectorId == step.SelectorId && sr.Step.Value == step.Value); stepResult.Attempts++; } }
public void capture_error_on_the_second_frame() { var errors = new StepResults(); errors.MoveFrame(); errors.CaptureException("anything"); errors.MoveFirst(); errors.HasErrors().ShouldBeFalse(); errors.MoveFrame(); errors.HasErrors().ShouldBeTrue(); }
void Ex08() { Given("WhenStep that has an action that does not throw any exceptions", () => { Step = FixtureSteps.CreateWhenStep(() => { }); ExpectedResult = FixtureStepResultAssertion.ForNullException(FixtureStepStatus.Pending, Step); }); Given("a result of GivenStep that has Passed status", () => StepResults.Add(FixtureStepResult.Of(FixtureSteps.CreateGivenStep()).Passed().Build())); Given("a result of WhenStep that has Pending status", () => StepResults.Add(FixtureStepResult.Of(FixtureSteps.CreateWhenStep()).Pending().Build())); When("the given WhenStep is run", () => Result = RunnerOf(Step).Run(StepResults).Build()); Then($"the result should be as follows:{ExpectedResult.ToDescription()}", () => FixtureStepResultAssertion.Of(Result) == ExpectedResult); }
public void SetUp() { cell = Cell.For <string>("name"); cell.IsResult = true; step = new Step().With("name:Jeremy"); result = new StepResults(); result.SetActual("name", "Jeremy"); tag = new CellTag(cell, step); tag.WriteResults(result, new TestContext()); }
void Ex13() { Given("ThenStep that has an assertion without Exception that returns true", () => { Step = FixtureSteps.CreateThenStep(() => true); ExpectedResult = FixtureStepResultAssertion.ForNullException(FixtureStepStatus.Pending, Step); }); Given("a result of GivenStep that has Passed status", () => StepResults.Add(FixtureStepResult.Of(FixtureSteps.CreateGivenStep()).Passed().Build())); Given("a result of WhenStep that has Pending status", () => StepResults.Add(FixtureStepResult.Of(FixtureSteps.CreateWhenStep()).Pending().Build())); When("the given ThenStep is run", () => Result = RunnerOf(Step).Run(StepResults).Build()); Then($"the result should be as follows:{ExpectedResult.ToDescription()}", () => FixtureStepResultAssertion.Of(Result) == ExpectedResult); }
void Ex05() { Given("ExpectStep that has an assertion that returns true", () => { Step = FixtureSteps.CreateExpectStep(() => true); ExpectedResult = FixtureStepResultAssertion.ForNullException(FixtureStepStatus.Ready, Step); }); Given("a result of GivenStep that does not have Ready status", () => StepResults.Add(FixtureStepResult.Of(FixtureSteps.CreateGivenStep()).Passed().Build())); Given("a result of WhenStep that has Ready status", () => StepResults.Add(FixtureStepResult.Of(FixtureSteps.CreateWhenStep()).Ready().Build())); When("the given ExpectStep is run", () => Result = RunnerOf(Step).Run(StepResults).Build()); Then($"the result should be as follows:{ExpectedResult.ToDescription()}", () => FixtureStepResultAssertion.Of(Result) == ExpectedResult); }
public StepResults Compile(string revision, string configFile) { this.revision = revision; Stopwatch sw = new Stopwatch(); sw.Start(); StepResults sr = new StepResults(); sr.Command = "monocompiler"; // Create a log file try { // Load the configuration file XmlDocument doc = new XmlDocument(); doc.Load(configFile); queue = new SerialWorkQueue(doc); List <Thread> threads = new List <Thread> (); for (int i = 0; i < 1; i++) { Thread t = new Thread(new ThreadStart(WorkerThread)); threads.Add(t); t.Start(); } foreach (Thread t in threads) { t.Join(); } // Report results sr.ExitCode = 0; sb.AppendLine("Done"); } catch (Exception ex) { //Console.WriteLine (ex.ToString ()); sr.ExitCode = 1; sb.AppendFormat("MonoCompiler Error:\n{0}\n", ex.ToString()); } sw.Stop(); //Console.WriteLine (sw.Elapsed); sr.ExecutionTime = sw.Elapsed; sr.Log = sb.ToString(); return(sr); }
private void UpdateStepResults(ScenarioResult result) { var actionStepResults = StepResults.ToArray(); var idx = 0; foreach (var stepResult in result.StepResults) { var step = actionStepResults[idx++]; MergeStepResult(stepResult, step); MergeResult(stepResult); } }
public void collapse_is_idempotent() { var result = new StepResults(); result.MoveFrame(); result.MoveFrame(); result.MoveFrame(); result.CaptureException("bad"); result.Collapse(); result.Collapse(); result.Collapse(); result.ExceptionText.ShouldEqual("bad"); }
public void clear_will_clear_out_the_frame_errors() { var errors = new StepResults(); errors.MoveFrame(); errors.MoveFrame(); errors.CaptureException("anything"); errors.Clear(); errors.MoveFirst(); errors.MoveFrame(); errors.MoveFrame(); errors.HasErrors().ShouldBeFalse(); }
public override void AddActionStepResult(StepResult stepResult) { MergeResult(stepResult); var step = StepResults.FirstOrDefault(s => s.StringStep == stepResult.StringStep); if (step == null) { base.AddActionStepResult(stepResult); } else { MergeStepResult(stepResult, step); } }
public void SetUp() { sentence = Sentence.For("{name} is {age}", Cell.For <string>("name"), Cell.For <int>("age")); step = new Step().With("name:Max,age:6"); tag = new SentenceTag(sentence, step); context = new TestContext(); StepResults results = context.ResultsFor(step); results.CaptureException("bad stuff"); results.ExceptionText.ShouldEqual("bad stuff"); tag.WriteResults(context); }
public StepResult(Type stepType, StepResults result) { if (stepType == null) { throw new ArgumentNullException("stepType", "Step type not specified."); } if (!TypeUtils.IsSubclassOf(stepType, typeof(AMainStrategyStepBase))) { throw new ArgumentOutOfRangeException("stepType", "Step type is not inherited from base step type."); } StepType = stepType.FullName; Result = result; } // constructor
public void SetUp() { grammar = Fixture.VerifyStringList(() => { throw new NotImplementedException(); }).Titled( "The list of strings should be").LeafNameIs("row").Grammar(); step = new Step("anything").WithChildren("row", new Step(), new Step(), new Step()); var context = new TestContext(); grammar.Execute(step, context); counts = context.Counts; rowResults = context.ResultsFor(step).GetResult<IList<SetRow>>(grammar.LeafName); stepResults = context.ResultsFor(step); }
public void collapse_with_a_hierarchy() { var result = new StepResults(); result.MoveFrame(); result.MoveFrame(); result.MoveFrame(); result.CaptureException("bad"); result.MoveFrame(); result.MoveFrame(); result.CaptureException("worse"); result.Collapse(); result.HasErrors().ShouldBeTrue(); result.ExceptionText.ShouldContain("bad"); result.ExceptionText.ShouldContain("worse"); }
public StepResults Compile(string revision, string configFile) { this.revision = revision; Stopwatch sw = new Stopwatch (); sw.Start (); StepResults sr = new StepResults (); sr.Command = "monocompiler"; // Create a log file try { // Load the configuration file XmlDocument doc = new XmlDocument (); doc.Load (configFile); queue = new SerialWorkQueue (doc); List<Thread> threads = new List<Thread> (); for (int i = 0; i < 1; i++) { Thread t = new Thread (new ThreadStart (WorkerThread)); threads.Add (t); t.Start (); } foreach (Thread t in threads) t.Join (); // Report results sr.ExitCode = 0; sb.AppendLine ("Done"); } catch (Exception ex) { //Console.WriteLine (ex.ToString ()); sr.ExitCode = 1; sb.AppendFormat ("MonoCompiler Error:\n{0}\n", ex.ToString ()); } sw.Stop (); //Console.WriteLine (sw.Elapsed); sr.ExecutionTime = sw.Elapsed; sr.Log = sb.ToString (); return sr; }
public void SetUp() { cell = Cell.For<string>("name"); cell.IsResult = true; step = new Step().With("name:Jeremy"); result = new StepResults(); //result.SetActual("name", "Chad"); result.MarkFailure("name"); tag = new CellTag(cell, step); tag.WriteResults(result, new TestContext()); }
public void SetUp() { step = new Step("a").With("key1", "abc"); cell = new Cell("key1", typeof (int)); var context = new TestContext(); cell.ReadArgument(context, step, x => Assert.Fail("should not have called me")); counts = context.Counts; results = context.ResultsFor(step); }
public void reset_clears_exception_text_and_has_errors() { var errors = new StepResults(); errors.MarkMissingValue("a"); errors.Clear(); errors.HasErrors().ShouldBeFalse(); errors.ExceptionText.ShouldBeEmpty(); errors.CaptureException(new NotImplementedException().ToString()); errors.Clear(); errors.HasErrors().ShouldBeFalse(); errors.ExceptionText.ShouldBeEmpty(); }