private bool validateOnly(RunInput input, SystemRecycled systemRecycled) { var fixtures = buildFixturesWithOverrides(input, systemRecycled); var library = FixtureLibrary.From(fixtures); var specs = HierarchyLoader.ReadHierarchy(input.SpecPath).GetAllSpecs().ToArray(); SpecificationPostProcessor.PostProcessAll(specs, library); var errored = specs.Where(x => x.errors.Any()).ToArray(); if (errored.Any()) { ConsoleWriter.Write(ConsoleColor.Red, "Errors Detected!"); foreach (var errorSpec in errored) { ConsoleWriter.Write(ConsoleColor.Yellow, errorSpec.Filename); foreach (var error in errorSpec.errors) { Console.WriteLine($"{error.location.Join(" / ")} -> {error.message}"); } } return(false); } else { ConsoleWriter.Write(ConsoleColor.Green, "No validation errors or missing data detected in this project"); return(true); } }
public override bool Execute(RunInput input) { try { var top = HierarchyLoader.ReadHierarchy(input.SpecPath); var specs = input.GetBatchRunRequest().Filter(top); if (!specs.Any()) { ConsoleWriter.Write(ConsoleColor.Yellow, "Warning: No specs found!"); } } catch (SuiteNotFoundException ex) { ConsoleWriter.Write(ConsoleColor.Red, ex.Message); return(false); } var controller = input.BuildEngine(); var task = controller.Start().ContinueWith(t => { var systemRecycled = t.Result; return(executeAgainstTheSystem(input, systemRecycled, controller)); }); task.Wait(); controller.SafeDispose(); return(task.Result); }
public SpecExecutionRequestTester() { var path = ".".ToFullPath().ParentDirectory().ParentDirectory().ParentDirectory() .AppendPath("Storyteller.Samples", "Specs", "General", "Check properties.xml"); theSpec = HierarchyLoader.ReadSpecHeader(path); }
public void the_spec_type_should_be_header_after_loading_a_spec_as_header() { var path = ".".ToFullPath().ParentDirectory().ParentDirectory().ParentDirectory() .AppendPath("Storyteller.Samples", "Specs", "General", "Check properties.xml"); var spec = HierarchyLoader.ReadSpecHeader(path); spec.SpecType.ShouldBe(SpecType.header); }
public BatchRunRequest GetBatchRunRequest() { var tagsString = ExcludeTagsFlag ?? ""; var top = HierarchyLoader.ReadHierarchy(SpecPath); var tags = tagsString.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries).Select(x => x.Trim()).ToArray(); var specs = HierarchyLoader.Filter(top, LifecycleFlag, WorkspaceFlag, tags).ToList(); return(new BatchRunRequest(specs)); }
public void can_read_max_retries() { var path = ".".ToFullPath().ParentDirectory().ParentDirectory().ParentDirectory() .AppendPath("Storyteller.Samples", "Specs", "General", "Check properties.xml"); var spec = HierarchyLoader.ReadSpecHeader(path); spec.MaxRetries.ShouldBe(3); }
public void pretty_print_for_sample_data() { var path = TestingContext.FindParallelDirectory("Storyteller.Samples").AppendPath("Specs"); var hierarchy = HierarchyLoader.ReadHierarchy(path); var json = JsonSerialization.ToJson(hierarchy).FormatJson(); Debug.WriteLine(json); }
public void filter_by_including_multiple_tags() { var specs = HierarchyLoader.Filter(theHierarchy, Lifecycle.Any, includeTags: new string[] { "check", "do" }) .Select(x => x.path).ToArray(); specs.Length.ShouldBe(5); specs.ShouldContain("General/Check properties"); specs.ShouldContain("General/Occasionally Times Out"); }
public void CreateMissingSpecFolder() { var specFolder = HierarchyLoader.SelectSpecPath(Path.ToFullPath()); if (!Directory.Exists(specFolder)) { Console.WriteLine("Creating /Specs folder at " + specFolder); Directory.CreateDirectory(specFolder); } }
public void filter_by_excluding_tags() { var paths = HierarchyLoader.Filter(theHierarchy, Lifecycle.Any, excludeTags: new string[] { "check" }) .Select(x => x.path).ToArray(); paths.ShouldNotContain("General/Check properties"); paths.ShouldNotContain("Paragraphs/Composite with Errors"); paths.ShouldNotContain("Sentences/Currying"); }
public void convert_the_top_suite_to_a_hierarchy_gets_the_specs() { var path = TestingContext.FindParallelDirectory("Storyteller.Samples").AppendPath("Specs"); var hierarchy = HierarchyLoader.ReadHierarchy(path).ToHierarchy(); hierarchy.Specifications["embeds"].ShouldNotBeNull(); hierarchy.Specifications["sentence1"].ShouldNotBeNull(); hierarchy.Specifications["sentence2"].ShouldNotBeNull(); }
public void SetUp() { theHierarchy = HierarchyLoader.ReadHierarchy(TestingContext.SpecFolder).ToHierarchy(); theOriginal = theHierarchy.Specifications["embeds"]; theNew = theOriginal.Clone(); theNew.path = null; theNew.id = theOriginal.id; // gets a new id by default theTime = DateTime.Now; theHierarchy.Replace(theNew, theTime); }
public Task <List <Specification> > ReadSpecs() { return(Task.Factory.StartNew(() => { ConsoleWriter.Write(ConsoleColor.Cyan, "Reading specifications from " + SpecPath); var top = HierarchyLoader.ReadHierarchy(SpecPath); // TODO -- filter on tags here // TODO -- make HierarchyLoader smart enough to recognize spec or suite return HierarchyLoader.Filter(top, LifecycleFlag, SpecificationOrSuite, new string[0]).ToList(); })); }
public StorytellerRunner(ISystem system, string specDirectory = null) { Debug.WriteLine("StorytellerRunner is starting up for system " + system); SpecDirectory = specDirectory ?? GuessSpecDirectory(system); _running = RunningSystem.Create(system); Hierarchy = HierarchyLoader.ReadHierarchy(SpecDirectory).ToHierarchy(); _warmup = _running.System.Warmup(); }
public StorytellerRunner(ISystem system, string specDirectory = null) { Debug.WriteLine("StorytellerRunner is starting up for system " + system); SpecDirectory = specDirectory ?? GuessSpecDirectory(system); _system = system; _library = FixtureLibrary.CreateForAppDomain(_system.Start()); Hierarchy = HierarchyLoader.ReadHierarchy(SpecDirectory).ToHierarchy(); _warmup = _system.Warmup(); }
public void pretty_print_for_sample_data() { var path = ".".ToFullPath().ParentDirectory().ParentDirectory().ParentDirectory() .AppendPath("Storyteller.Samples", "Specs"); var hierarchy = HierarchyLoader.ReadHierarchy(path); var json = JsonSerialization.ToJson(hierarchy).FormatJson(); Debug.WriteLine(json); }
public static string GuessSpecDirectory() { var path = AppContext.BaseDirectory; while (Path.GetFileName(path).EqualsIgnoreCase("bin") || Path.GetFileName(path).EqualsIgnoreCase("debug") || Path.GetFileName(path).EqualsIgnoreCase("release")) { path = path.ParentDirectory(); } return(HierarchyLoader.SelectSpecPath(path)); }
public void convert_the_top_suite_to_a_hierarchy_gets_the_suites() { var path = TestingContext.FindParallelDirectory("Storyteller.Samples").AppendPath("Specs"); var hierarchy = HierarchyLoader.ReadHierarchy(path).ToHierarchy(); hierarchy.Suites[string.Empty].ShouldNotBeNull(); hierarchy.Suites[string.Empty].suites.Count().ShouldBe(6); hierarchy.Suites.Select(x => x.path) .ShouldHaveTheSameElementsAs("", "Embedded", "General", "Paragraphs", "Sentences", "Sets", "Tables"); }
public SpecRunner(string specDirectory = null) { Debug.WriteLine("SpecRunner is starting up for system " + typeof(T).FullName); Debug.WriteLine("using {0} as the configuration file", AppDomain.CurrentDomain.SetupInformation.ConfigurationFile); SpecDirectory = specDirectory ?? GuessSpecDirectory(); _system = new T(); _library = FixtureLibrary.CreateForAppDomain(_system.Start()); _hierarchy = HierarchyLoader.ReadHierarchy(SpecDirectory).ToHierarchy(); _warmup = _system.Warmup(); }
protected override void Initialize(Type suiteType, object suite, SuiteProvider provider) { var hierarchyTypes = HierarchyLoader.GetExecutionHierarchy(suiteType).ToList(); var behaviorTypes = suiteType.Descendants(x => GetBehaviorTypes(x)).ToList(); var setupOperationProviders = GetSetupOperationProviders(hierarchyTypes, behaviorTypes, suite, suiteType); var assertionFields = GetFields <It>(suiteType).Concat(behaviorTypes.SelectMany(GetFields <It>)); var testProviders = assertionFields.Select(x => CreateTestProvider(provider.Identity, GetInstance(x.DeclaringType.NotNull(), suite), x)); provider.ContextProviders = setupOperationProviders; provider.TestProviders = testProviders; }
public void write_initial_model() { // You need to compile everything before trying to use this var input = new ProjectInput { Path = AppDomain.CurrentDomain.BaseDirectory.ParentDirectory() .ParentDirectory() .ParentDirectory() .AppendPath("Storyteller.Samples"), ProfileFlag = "Safari" }; using (var controller = input.BuildRemoteController()) { controller.Start(EngineMode.Batch).Wait(30.Seconds()); var hierarchy = HierarchyLoader.ReadHierarchy(input.Path.AppendPath("Specs")); var request = new BatchRunRequest { SpecPath = input.SpecPath }; var response = controller.Send(request).AndWaitFor <BatchRunResponse>(); var cache = new ResultsCache(); response.Result.records.Each( x => { var completed = new SpecExecutionCompleted(x.specification.id, x.results, x.specification); cache.Store(completed); }); response.Result.fixtures = controller.LatestSystemRecycled.fixtures; var hierarchyLoaded = new HierarchyLoaded(hierarchy, cache); var initialization = new InitialModel(controller.LatestSystemRecycled, hierarchyLoaded) { wsAddress = "ws://localhost:" + 8200 }; writeResponse(response.Result); //writeInitialization(initialization); } }
public void read_a_spec_node() { var path = ".".ToFullPath().ParentDirectory().ParentDirectory().ParentDirectory() .AppendPath("Storyteller.Samples", "Specs", "General", "Check properties.xml"); var spec = HierarchyLoader.ReadSpecHeader(path); spec.name.ShouldBe("Check properties"); spec.Lifecycle.ShouldBe(Lifecycle.Acceptance); spec.id.ShouldBe("general1"); spec.Filename.ShouldBe(path); spec.MaxRetries.ShouldBe(3); }
public virtual void ReloadHierarchy() { try { _lock.Write(() => { _hierarchy = HierarchyLoader.ReadHierarchy(_specPath).ToHierarchy(); SendHierarchyToClient(); }); } catch (Exception e) { _logger.Error("Failed to reload the spec hierarchy", e); } }
public virtual void ReloadHierarchy() { try { _lock.Write(() => { _hierarchy = HierarchyLoader.ReadHierarchy(_specPath).ToHierarchy(); _fixtures.PostProcessAll(_hierarchy.Specifications); SendHierarchyToClient(); }); } catch (Exception e) { Logger.Error("Failed to reload the spec hierarchy", e); } }
public void Test() { var hierarchy = HierarchyLoader.GetExecutionHierarchy(typeof(U3.U6)).ToList(); var expectedHierarchy = new[] { typeof(U1), typeof(X1.U2), typeof(U3), typeof(U4), typeof(X2.U5), typeof(U3.U6) }; Assert.That(hierarchy, Is.EqualTo(expectedHierarchy)); }
public void StartWatching(string path) { try { _specPath = path.ToFullPath(); _lock.Write(() => { _hierarchy = HierarchyLoader.ReadHierarchy(_specPath).ToHierarchy(); }); _watcher.StartWatching(path, this); } catch (Exception e) { _logger.Error("Failed to start watching spec files", e); } }
public void read_spec_data_from_header_mode() { var path = ".".ToFullPath().ParentDirectory().ParentDirectory().ParentDirectory() .AppendPath("Storyteller.Samples", "Specs", "General", "Check properties.xml"); var spec = HierarchyLoader.ReadSpecHeader(path); spec.Children.Any().ShouldBeFalse(); spec.SpecType.ShouldBe(SpecType.header); spec.ReadBody(); spec.SpecType.ShouldBe(SpecType.full); spec.Children.Any().ShouldBeTrue(); }
public void Receive(BatchRunRequest message) { var top = HierarchyLoader.ReadHierarchy(); var specs = message.Filter(top).ToArray(); var task = _resultObserver.MonitorBatch(specs); specs .Select(SpecExecutionRequest.For) .Each(x => _engine.Enqueue(x)); task.ContinueWith(t => { EventAggregator.SendMessage(new BatchRunResponse { records = t.Result.ToArray() }); }); }
public static string GuessSpecDirectory(ISystem system) { #if NET46 var path = AppDomain.CurrentDomain.BaseDirectory; #else var path = AppContext.BaseDirectory; #endif var projectName = system.GetType().GetTypeInfo().Assembly.GetName().Name; var fileName = Path.GetFileName(path); while (fileName != projectName && !Directory.Exists(path.AppendPath("Specs"))) { path = path.ParentDirectory(); fileName = Path.GetFileName(path); } return(HierarchyLoader.SelectSpecPath(path)); }
public void read_an_entire_suite() { var path = TestingContext.FindParallelDirectory("Storyteller.Samples").AppendPath("Specs"); var hierarchy = HierarchyLoader.ReadHierarchy(path); hierarchy.suites.Select(x => x.name) .ShouldHaveTheSameElementsAs("Embedded", "General", "Paragraphs", "Sentences", "Sets", "Tables"); /* var serializer = new Newtonsoft.Json.JsonSerializer(); var writer = new StringWriter(); serializer.Serialize(writer, hierarchy); var json = writer.ToString(); Debug.WriteLine(json); * */ }