/// <summary> /// Creates a test run object from a text file. /// </summary> /// <param name="text">The text report to import.</param> /// <param name="indentationKey">The string used for indentation in the text file.</param> /// <param name="rootNamespace">The namspace to prepend to each capability.</param> /// <param name="defaultOutcome">The default outcome for a scenario.</param> /// <param name="defaultReason">The default reason for an scenario.</param> /// <returns>TestRun object hydrated from the text file outline.</returns> public TestRun ImportText( string text, string indentationKey = "\t", string rootNamespace = "", string defaultOutcome = "Skipped", string defaultReason = "Defining") { if (text.Length == 0) { throw new Exception("The file is empty."); } this.indentationKey = indentationKey; this.defaultOutcome = (Outcome)Enum.Parse(typeof(Outcome), defaultOutcome); this.rootNamespace = rootNamespace; this.defaultReason = defaultReason; string[] lines = text.Split( new[] { Environment.NewLine }, StringSplitOptions.None ); var factory = new CoreFactory(); var testRunBuilder = factory.CreateTestRunBuilder(Configuration.TestRunName); var currentTestRunBuilder = xB.CurrentRun; xB.CurrentRun = testRunBuilder; try { this.ProcessLines(lines); } catch { xB.CurrentRun = currentTestRunBuilder; throw; } xB.CurrentRun.TestRun.SortTestRunResults(this.featureNames); xB.CurrentRun.TestRun.Scenarios.ForEach(scenario => { if (scenario.Outcome == Outcome.NotRun) { scenario.Outcome = this.defaultOutcome; } if (scenario.Reason == null) { scenario.Reason = this.defaultReason; } }); var testRun = xB.CurrentRun.TestRun; xB.CurrentRun = currentTestRunBuilder; return(testRun); }
public async Task AllPassing() { var factory = new CoreFactory(); xB.CurrentRun = factory.CreateTestRunBuilder("Test Run"); var tr = await TestRunSetup.BuildTestRun(); var reasons = new List <string>() { "Removing", "Building", "Untested", "Ready", "Defining" }; xB.CurrentRun.TestRun.UpdateParentReasonsAndStats(reasons); this.ValidateTestResuls(tr); }
public async Task AllPassing() { var factory = new CoreFactory(); xB.CurrentRun = factory.CreateTestRunBuilder("Test Run"); var tr = await TestRunSetup.BuildTestRun(); var reasons = new List <string>() { "Removing", "Building", "Untested", "Ready", "Defining" }; var features = new List <string>() { }; xB.Complete("xBDDConfig.json", features, (message) => { Logger.LogMessage(message); }); }
public async Task OneFailingFirstStepTest() { var factory = new CoreFactory(); xB.CurrentRun = factory.CreateTestRunBuilder("Test Run"); var skippedScenarioIds = new Dictionary <string, string>(); skippedScenarioIds.Add("010101", "Building"); skippedScenarioIds.Add("010102", "Untested"); skippedScenarioIds.Add("010201", "Untested"); skippedScenarioIds.Add("010202", "Ready"); skippedScenarioIds.Add("010301", "Ready"); skippedScenarioIds.Add("010302", "Defining"); skippedScenarioIds.Add("020101", "Building"); skippedScenarioIds.Add("020201", "Untested"); skippedScenarioIds.Add("020301", "Ready"); var tr = await TestRunSetup.BuildTestRun(null, skippedScenarioIds); var reasons = new List <string>() { "Removing", "Building", "Untested", "Ready", "Defining" }; xB.CurrentRun.TestRun.UpdateParentReasonsAndStats(reasons); var statsOverrides = new Dictionary <string, Dictionary <string, int> >(); statsOverrides.Add("Testrun-capabilities", new Dictionary <string, int>() { { "Defining", 1 }, { "Ready", 1 } }); statsOverrides.Add("Testrun-features", new Dictionary <string, int>() { { "Building", 1 }, { "Untested", 2 }, { "Ready", 2 }, { "Defining", 1 } }); statsOverrides.Add("Testrun-scenarios", new Dictionary <string, int>() { { "Building", 2 }, { "Untested", 3 }, { "Ready", 3 }, { "Defining", 1 } }); statsOverrides.Add("Capability 01-features", new Dictionary <string, int>() { { "Untested", 1 }, { "Ready", 1 }, { "Defining", 1 } }); statsOverrides.Add("Capability 01-scenarios", new Dictionary <string, int>() { { "Building", 1 }, { "Untested", 2 }, { "Ready", 2 }, { "Defining", 1 } }); statsOverrides.Add("Capability 02-features", new Dictionary <string, int>() { { "Building", 1 }, { "Untested", 1 }, { "Ready", 1 } }); statsOverrides.Add("Capability 02-scenarios", new Dictionary <string, int>() { { "Building", 1 }, { "Untested", 1 }, { "Ready", 1 } }); statsOverrides.Add("Feature 0101-scenarios", new Dictionary <string, int>() { { "Building", 1 }, { "Untested", 1 } }); statsOverrides.Add("Feature 0102-scenarios", new Dictionary <string, int>() { { "Untested", 1 }, { "Ready", 1 } }); statsOverrides.Add("Feature 0103-scenarios", new Dictionary <string, int>() { { "Ready", 1 }, { "Defining", 1 } }); statsOverrides.Add("Feature 0201-scenarios", new Dictionary <string, int>() { { "Building", 1 } }); statsOverrides.Add("Feature 0202-scenarios", new Dictionary <string, int>() { { "Untested", 1 } }); statsOverrides.Add("Feature 0203-scenarios", new Dictionary <string, int>() { { "Ready", 1 } }); var outcomeOverrides = new Dictionary <string, string>(); outcomeOverrides.Add("Testrun", "Defining"); outcomeOverrides.Add("Capability 01", "Defining"); outcomeOverrides.Add("Capability 02", "Ready"); outcomeOverrides.Add("Feature 0101", "Untested"); outcomeOverrides.Add("Feature 0102", "Ready"); outcomeOverrides.Add("Feature 0103", "Defining"); outcomeOverrides.Add("Scenario 010101", "Building"); outcomeOverrides.Add("Scenario 010102", "Untested"); outcomeOverrides.Add("Scenario 010201", "Untested"); outcomeOverrides.Add("Scenario 010202", "Ready"); outcomeOverrides.Add("Scenario 010301", "Ready"); outcomeOverrides.Add("Scenario 010302", "Defining"); outcomeOverrides.Add("Feature 0201", "Building"); outcomeOverrides.Add("Feature 0202", "Untested"); outcomeOverrides.Add("Feature 0203", "Ready"); outcomeOverrides.Add("Scenario 020101", "Building"); outcomeOverrides.Add("Scenario 020201", "Untested"); outcomeOverrides.Add("Scenario 020301", "Ready"); this.ValidateTestResuls(tr, statsOverrides, outcomeOverrides); }