Esempio n. 1
0
        public void TestFileName()
        {
            var finishDateTime = new DateTime(2018, 10, 25, 5, 45, 55);
            var testFileName   = NamesProvider.GetTestRunFileName(finishDateTime);

            Assert.AreEqual($"test_{finishDateTime:yyyyMMdd_HHmmssfff}.json", testFileName);
        }
Esempio n. 2
0
        public static string Save(this TestRunDto testRun, string path)
        {
            path.Create();
            var fullPath = Path.Combine(path, NamesProvider.GetTestRunFileName(testRun.TestInfo.Finish));

            using (var file = File.CreateText(fullPath))
            {
                var serializer = new JsonSerializer();
                serializer.Serialize(file, testRun);
            }
            return(fullPath);
        }
Esempio n. 3
0
        public static ItemInfo MapTestRunInfo(this ItemInfoDto itemInfoDto)
        {
            var run = new ItemInfo
            {
                Guid     = itemInfoDto.Guid,
                Start    = itemInfoDto.Start,
                Finish   = itemInfoDto.Finish,
                ItemName = NamesProvider.GetTestRunFileName(itemInfoDto.Finish)
            };

            return(run);
        }
        public void UpdateTestOutput(ItemInfoDto testInfo, TestOutputDto testOutput)
        {
            testInfo.ItemName = NamesProvider.GetTestRunFileName(testInfo.Finish);
            testOutput.TestOutputInfo.ItemName = NamesProvider.GetTestOutputFileName(testInfo.Finish);
            var outputFolderPath = _locationsProvider.GetTestOutputFolderPath(testInfo.Guid);
            var outputFileName   = NamesProvider.GetTestOutputFileName(testInfo.Finish);
            var existingOutput   = Path.Combine(outputFolderPath, outputFileName).LoadTestOutput();

            _logger.Debug($"Loaded existing output: {JsonConvert.SerializeObject(existingOutput, Formatting.Indented)}");
            existingOutput.SuiteOutput = testOutput.SuiteOutput;
            existingOutput.Output      = testOutput.Output;
            File.Delete(Path.Combine(outputFolderPath, outputFileName));
            _logger.Debug("Deleted old output");
            existingOutput.Save(outputFolderPath);
            _logger.Debug($"Saved updated output: {JsonConvert.SerializeObject(existingOutput, Formatting.Indented)}");
        }
        public ItemInfoDto SaveTestRun(TestRunDto testRun, TestOutputDto testOutput)
        {
            testRun.TestInfo.ItemName          = NamesProvider.GetTestRunFileName(testRun.TestInfo.Finish);
            testOutput.TestOutputInfo.ItemName = NamesProvider.GetTestOutputFileName(testRun.TestInfo.Finish);
            testRun.Output.ItemName            = testOutput.TestOutputInfo.ItemName;
            var imgFolder = _locationsProvider.GetScreenshotFolderPath(testRun.TestInfo.Guid);

            if (Directory.Exists(imgFolder))
            {
                var imgFiles = new DirectoryInfo(imgFolder).GetFiles("*.json");
                _logger.Info($"Checking unassigned img files: {imgFiles.Length} file found");
                foreach (var imgFile in imgFiles)
                {
                    var img = Path.Combine(imgFolder, imgFile.Name).LoadTestScreenshot();
                    if (imgFile.CreationTime > testRun.TestInfo.Start)
                    {
                        _logger.Info($"New img file found: {imgFile.CreationTime}, {imgFile.Name}");
                        if (testRun.Screenshots.All(s => s.Date != img.TestScreenshotInfo.Date))
                        {
                            testRun.Screenshots.Add(img.TestScreenshotInfo);
                        }
                    }
                }
            }
            var testOutputFullPath = testOutput.Save(_locationsProvider.GetTestOutputFolderPath(testRun.TestInfo.Guid));

            _logger.Info($"Test output was saved: '{testOutputFullPath}'");
            _logger.Debug($"Test run output data was saved correctly: {JsonConvert.SerializeObject(testOutput, Formatting.Indented)}");
            var testRunFullPath = testRun.Save(_locationsProvider.GetTestFolderPath(testRun.TestInfo.Guid));

            _logger.Info($"Test run was saved: '{testRunFullPath}'");
            var testRunsInfoFullPath = testRun.TestInfo.SaveTestInfo(_locationsProvider);

            _logger.Info($"Test runs Info was saved: '{testRunsInfoFullPath}'");
            _logger.Debug($"Test run data was saved correctly: {JsonConvert.SerializeObject(testRun, Formatting.Indented)}");

            if (!_processedTests.ContainsKey(testRun.TestInfo.Guid))
            {
                _processedTests.Add(testRun.TestInfo.Guid, testRun.TestInfo);
            }

            return(testRun.TestInfo);
        }