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);
        }
Пример #3
0
        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));
        }
Пример #4
0
        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);
        }
Пример #5
0
        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);
        }
Пример #6
0
        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();
        }
Пример #7
0
        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();
        }
Пример #8
0
        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();
            }));
        }
Пример #9
0
        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);
        }
Пример #10
0
        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();
        }
Пример #11
0
        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();
        }
Пример #12
0
        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");
        }
Пример #13
0
        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 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 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);
            }
        }
Пример #16
0
 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);
     }
 }
Пример #17
0
        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()
                });
            });
        }
Пример #18
0
        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);
             * */
        }
        //[Fact]
        public void write_initial_model()
        {
            // You need to compile everything before trying to use this
            var input = new ProjectInput(EngineMode.Batch)
            {
                Path =
                    samplesFolder,
                ProfileFlag = "Safari"
            };

            using (var controller = input.BuildEngine())
            {
                controller.Start().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);

                writeResponse(response.Result);
                //writeInitialization(initialization);
            }
        }
Пример #20
0
        public override bool Execute(ExportInput input)
        {
            var top = HierarchyLoader.ReadHierarchy(input.SpecPath);

            using (var controller = input.BuildEngine())
            {
                var fixtures = DumpFixturesCommand.BuildCombinedFixtureLibrary(input, controller);

                var doc = ExportWriter.Build(top, fixtures, input.TitleFlag);

                Console.WriteLine("Exporting the specifications to " + input.FileFlag);
                doc.WriteToFile(input.FileFlag);
            }

            if (input.OpenFlag)
            {
                Console.WriteLine("Trying to open the file " + input.FileFlag);
                ProcessLauncher.OpenFile(input.FileFlag);
            }

            return(true);
        }
Пример #21
0
        public override bool Execute(StorytellerInput input)
        {
            var running = RunningSystem.Create(input.System);

            using (running.System)
            {
                var library = input.BuildFixturesWithOverrides(running.RecycledMessage);



                var specs = HierarchyLoader.ReadHierarchy(input.SpecPath).GetAllSpecs().ToArray();

                SpecificationPostProcessor.PostProcessAll(specs, running.Fixtures);

                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 void Sync()
        {
            if (_settings.PurgeTestRail)
            {
                Purge();
            }

            List <Case> testCases = _testRailClient.GetCases(_settings.ProjectId);

            _logger.Debug("Found {NumberOfCases} cases for Project {ProjectId}", testCases.Count, _settings.ProjectId);

            Hierarchy hierarchy = HierarchyLoader
                                  .ReadHierarchy(_settings.SpecsFolder)
                                  .ToHierarchy();

            List <Section> sections = _testRailClient.GetSections(_settings.ProjectId);

            foreach (var spec in hierarchy.Specifications)
            {
                _logger.Verbose("Processing spec {SpecName}", spec.name);

                var suitePath = spec.SuitePath();

                if (!string.IsNullOrEmpty(_settings.BaseSectionPath))
                {
                    var basePath = _settings.BaseSectionPath;

                    if (!basePath.EndsWith("/"))
                    {
                        basePath += "/";
                    }

                    suitePath = basePath + suitePath;
                }

                List <Section> suiteSections = CreateSectionsFromSuitePath(suitePath).ToList();

                ProcessSuitePath(sections, suiteSections);

                Section section = suiteSections.Last();

                List <int> caseIds = TestCaseParser.ParseTestCaseIds(spec.name).ToList();

                Case existingCase = null;

                if (caseIds.Any())
                {
                    existingCase = testCases.FirstOrDefault(c => c.id == caseIds.First());
                }

                if (existingCase != null)
                {
                    _logger.Verbose("Spec {SpecName} is tied to C{CNumber}", spec.name, caseIds.First());

                    var cleanSpecName = CleanSpecName(spec.name);

                    if (existingCase.title != cleanSpecName)
                    {
                        existingCase.title = cleanSpecName;

                        _logger.Verbose("Updating {SpecName} in TestRail", spec.name);

                        _testRailClient.UpdateCase(existingCase);
                    }

                    if (existingCase.section_id != section.id)
                    {
                        existingCase.section_id = section.id;

                        _logger.Warning("{SpecName} will need manually moved to Section {@Section} in TestRail. Their API doesn't support moves", spec.name, section);
                    }
                }
                else
                {
                    _logger.Verbose("Adding {SpecName} to TestRail", spec.name);

                    Case newCase = _testRailClient.AddCase(new Case
                    {
                        title      = spec.name,
                        section_id = section.id
                    });

                    _logger.Verbose("Case {@Case} added to TestRail", newCase);

                    var specFile = File.ReadAllText(spec.Filename);

                    specFile = specFile.Replace(spec.name, $"{spec.name} [C{newCase.id}]");

                    File.WriteAllText(spec.Filename, specFile);
                }
            }
        }
Пример #23
0
 public void SetUp()
 {
     _hierarchy = HierarchyLoader.ReadHierarchy(_folder);
     _allSpecs  = _hierarchy.GetAllSpecs().ToArray();
 }
Пример #24
0
        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.BuildRemoteController();
            var task       = controller.Start(EngineMode.Batch).ContinueWith(t =>
            {
                var systemRecycled = t.Result;
                if (!systemRecycled.success)
                {
                    systemRecycled.WriteSystemUsage();
                    return(false);
                }

                writeSystemUsage(systemRecycled);
                var execution = input.StartBatch(controller);

                // TODO -- put a command level timeout on this thing
                execution.Wait();

                var results = execution.Result;

                var regression = results.Summarize(Lifecycle.Regression);
                var acceptance = results.Summarize(Lifecycle.Acceptance);

                if (input.LifecycleFlag != Lifecycle.Regression)
                {
                    Console.WriteLine(acceptance);
                }

                if (input.LifecycleFlag != Lifecycle.Acceptance)
                {
                    Console.WriteLine(regression);
                }

                var success = regression.Failed == 0;

                results.suite    = input.WorkspaceFlag;
                results.system   = systemRecycled.system_name;
                results.time     = DateTime.Now.ToString();
                results.fixtures = systemRecycled.fixtures;

                var document = BatchResultsWriter.BuildResults(results);
                Console.WriteLine("Writing results to " + input.ResultsPathFlag);
                document.WriteToFile(input.ResultsPathFlag);

                if (input.DumpFlag.IsNotEmpty())
                {
                    dumpJson(input, results);
                }

                if (input.CsvFlag.IsNotEmpty())
                {
                    writePerformanceData(input, results);
                }

                if (input.JsonFlag.IsNotEmpty())
                {
                    Console.WriteLine("Writing the raw result information to " + input.JsonFlag);
                    PerformanceDataWriter.WriteJSON(results, input.JsonFlag);
                }

                if (input.OpenFlag)
                {
                    Process.Start(input.ResultsPathFlag);
                }

                if (success)
                {
                    ConsoleWriter.Write(ConsoleColor.Green, "Success!");
                }
                else
                {
                    ConsoleWriter.Write(ConsoleColor.Red, "Failed with Regression Failures!");
                }

                return(success);
            });

            task.Wait();

            controller.SafeDispose();

            return(task.Result);
        }
 public Task <Suite> ReadHierarchy()
 {
     return(Task.Factory.StartNew(() => HierarchyLoader.ReadHierarchy(SpecPath)));
 }
Пример #26
0
 public Suite LoadHierarchy()
 {
     return(HierarchyLoader.ReadHierarchy(_path));
 }
 public integration_tests_with_the_grammar_project()
 {
     _hierarchy = HierarchyLoader.ReadHierarchy(_folder);
     _allSpecs  = _hierarchy.GetAllSpecs().ToArray();
 }
        public IntegratedHierarchyLoaderFilteringTests()
        {
            var directory = TestingContext.FindParallelDirectory("Storyteller.Samples").AppendPath("Specs");

            theHierarchy = HierarchyLoader.ReadHierarchy(directory);
        }