コード例 #1
0
        public void InitTest()
        {
            var logger   = new EmptyLogger();
            var settings = new ReporterSettings();
            var cache    = CommonCache.Instance;

            Assert.IsInstanceOf(typeof(CommonCache), cache.GetDataReader());
            Assert.IsInstanceOf(typeof(CommonCache), cache.GetDataWriter());
            Assert.Throws <NullReferenceException>(() => cache.SaveTestRun(new TestRunDto(), new TestOutputDto()));
            Assert.Throws <NullReferenceException>(() => cache.GetTestRun(new ItemInfoDto()));
            Assert.Throws <NullReferenceException>(() => cache.GetReportSettings());
            Assert.Throws <NullReferenceException>(() => cache.GetLatestTestRun(Guid.NewGuid()));
            Assert.Throws <NullReferenceException>(() => cache.GetRun(Guid.NewGuid()));
            Assert.Throws <NullReferenceException>(() => cache.GetRunInfos());
            Assert.Throws <NullReferenceException>(() => cache.GetTestInfos(Guid.NewGuid()));
            Assert.Throws <NullReferenceException>(() => cache.GetTestOutput(new TestRunDto()));
            Assert.Throws <NullReferenceException>(() => cache.GetTestRunsFromRun(new RunDto()));
            Assert.Throws <NullReferenceException>(() => cache.GetTestScreenshots(new TestRunDto()));
            Assert.Throws <NullReferenceException>(() => cache.SaveReportSettings(new ReportSettingsDto(1, 2, "", "")));
            Assert.Throws <NullReferenceException>(() => cache.SaveRun(new RunDto()));
            var scr = new TestScreenshotDto
            {
                Base64Data         = "adfas",
                Format             = "png",
                TestGuid           = Guid.NewGuid(),
                TestScreenshotInfo = new SimpleItemInfoDto {
                    Date = DateTime.Now, ItemName = "item"
                }
            };

            Assert.Throws <NullReferenceException>(() => cache.SaveScreenshot(scr));
            Assert.Throws <NullReferenceException>(() => cache.UpdateTestOutput(new ItemInfoDto(), new TestOutputDto()));
            Assert.Throws <NullReferenceException>(() => cache.DeleteRun(new ItemInfoDto()));
            Assert.Throws <NullReferenceException>(() => cache.DeleteTest(new TestRunDto()));
            Assert.Throws <NullReferenceException>(() => cache.DeleteTestOutput(new TestRunDto(), new TestOutputDto()));
            Assert.Throws <NullReferenceException>(() => cache.DeleteTestScreenshot(new TestRunDto(), new TestScreenshotDto()));
            cache.InitializeDataWriter(settings.DefaultSettings, logger);
            cache.InitializeDataReader(settings.DefaultSettings, logger);
            Assert.IsInstanceOf(typeof(CommonCache), cache.GetDataReader());
            Assert.IsInstanceOf(typeof(CommonCache), cache.GetDataWriter());
            Assert.DoesNotThrow(() => cache.SaveTestRun(new TestRunDto(), new TestOutputDto()));
            Assert.DoesNotThrow(() => cache.GetTestRun(new ItemInfoDto()));
            Assert.DoesNotThrow(() => cache.GetReportSettings());
            Assert.DoesNotThrow(() => cache.GetLatestTestRun(Guid.NewGuid()));
            Assert.DoesNotThrow(() => cache.GetRun(Guid.NewGuid()));
            Assert.DoesNotThrow(() => cache.GetRunInfos());
            Assert.DoesNotThrow(() => cache.GetTestInfos(Guid.NewGuid()));
            Assert.DoesNotThrow(() => cache.GetTestOutput(new TestRunDto()));
            Assert.DoesNotThrow(() => cache.GetTestRunsFromRun(new RunDto()));
            Assert.DoesNotThrow(() => cache.GetTestScreenshots(new TestRunDto()));
            Assert.DoesNotThrow(() => cache.SaveReportSettings(new ReportSettingsDto(1, 2, "", "")));
            Assert.DoesNotThrow(() => cache.SaveRun(new RunDto()));
            Assert.DoesNotThrow(() => cache.SaveScreenshot(scr));
            Assert.DoesNotThrow(() => cache.UpdateTestOutput(new ItemInfoDto(), new TestOutputDto()));
            Assert.DoesNotThrow(() => cache.DeleteRun(new ItemInfoDto()));
            Assert.DoesNotThrow(() => cache.DeleteTest(new TestRunDto()));
            Assert.DoesNotThrow(() => cache.DeleteTestOutput(new TestRunDto(), new TestOutputDto()));
            Assert.DoesNotThrow(() => cache.DeleteTestScreenshot(new TestRunDto(), scr));
            cache.TearDown();
        }
コード例 #2
0
ファイル: Reporter.cs プロジェクト: weedkiller/Ghpr.Core
        public void SaveScreenshot(byte[] screenshotBytes, string format = "png")
        {
            var now = DateTime.Now;

            while (!TestRunStarted && (DateTime.Now - now).TotalSeconds < 1)
            {
                Thread.Sleep(50);
            }
            var testGuid       = TestDataProvider.GetCurrentTestRunGuid();
            var base64String   = Convert.ToBase64String(screenshotBytes);
            var testScreenshot = new TestScreenshotDto
            {
                TestGuid           = testGuid,
                Base64Data         = base64String,
                TestScreenshotInfo = new SimpleItemInfoDto
                {
                    Date     = DateTime.Now,
                    ItemName = string.Empty
                },
                Format = format
            };

            Logger.Info($"Saving screenshot (Test guid: {testScreenshot.TestGuid})");
            DataWriterService.SaveScreenshot(testScreenshot);
        }
コード例 #3
0
        public SimpleItemInfoDto SaveScreenshot(TestScreenshotDto testScreenshot)
        {
            var screenshotEntity = testScreenshot.Map();

            Database.SaveScreenshot(screenshotEntity);
            return(screenshotEntity.Data.TestScreenshotInfo.ToDto());
        }
コード例 #4
0
        public SimpleItemInfoDto SaveScreenshot(TestScreenshotDto testScreenshot)
        {
            var res = _dataWriterService.SaveScreenshot(testScreenshot);

            _cache.SaveScreenshot(testScreenshot);
            return(res);
        }
コード例 #5
0
        public void DeleteTestScreenshot(TestRunDto testRun, TestScreenshotDto testScreenshot)
        {
            var testScreenshotFullPath = _locationsProvider
                                         .GetTestScreenshotFullPath(testRun.TestInfo.Guid, testScreenshot.TestScreenshotInfo.Date);

            _logger.Debug($"Deleting Test screenshot: {testScreenshotFullPath}");
            File.Delete(testScreenshotFullPath);
        }
コード例 #6
0
        public void SaveScreenshot(byte[] screenshotBytes)
        {
            var guid           = TestDataProvider.GetCurrentTestRunGuid();
            var testScreenshot = new TestScreenshotDto {
                TestGuid = guid, Data = screenshotBytes, Date = DateTime.Now
            };

            DataService.SaveScreenshot(testScreenshot);
        }
コード例 #7
0
        public SimpleItemInfoDto SaveScreenshot(TestScreenshotDto screenshotDto)
        {
            var testScreenshot = screenshotDto.Map();
            var path           = _locationsProvider.GetScreenshotFolderPath(testScreenshot.TestGuid);

            testScreenshot.Save(path);
            _logger.Info($"Screenshot was saved: '{path}'");
            _logger.Debug($"Screenshot data was saved correctly: {JsonConvert.SerializeObject(testScreenshot, Formatting.Indented)}");
            return(testScreenshot.TestScreenshotInfo.ToDto());
        }
コード例 #8
0
        public static TestScreenshotDto ToDto(this TestScreenshot testScreenshot)
        {
            var testScreenshotDto = new TestScreenshotDto
            {
                TestScreenshotInfo = testScreenshot.TestScreenshotInfo.ToDto(),
                Base64Data         = testScreenshot.Base64Data,
                TestGuid           = testScreenshot.TestGuid,
                Format             = testScreenshot.Format
            };

            return(testScreenshotDto);
        }
コード例 #9
0
        public static TestScreenshot Map(this TestScreenshotDto testScreenshotDto)
        {
            var name           = NamesProvider.GetScreenshotFileName(testScreenshotDto.TestScreenshotInfo.Date);
            var testScreenshot = new TestScreenshot
            {
                TestScreenshotInfo = testScreenshotDto.TestScreenshotInfo.MapSimpleItemInfo(name),
                Base64Data         = testScreenshotDto.Base64Data,
                TestGuid           = testScreenshotDto.TestGuid,
                Format             = testScreenshotDto.Format
            };

            return(testScreenshot);
        }
コード例 #10
0
        public static TestScreenshotDto LoadTestScreenshot(this string fullPath)
        {
            TestScreenshotDto testScreenshot = null;

            if (File.Exists(fullPath))
            {
                using (var file = File.OpenText(fullPath))
                {
                    var serializer = new JsonSerializer();
                    testScreenshot = (TestScreenshotDto)serializer.Deserialize(file, typeof(TestScreenshotDto));
                }
            }
            return(testScreenshot);
        }
コード例 #11
0
 public void SaveScreenshot(TestScreenshotDto testScreenshot)
 {
     using (var image = Image.FromStream(new MemoryStream(testScreenshot.Data)))
     {
         var screenPath = _locationsProvider.GetScreenshotPath(testScreenshot.TestGuid.ToString());
         screenPath.Create();
         var screenName = LocationsProvider.GetScreenshotFileName(testScreenshot.Date);
         var file       = Path.Combine(screenPath, screenName);
         var screen     = new Bitmap(image);
         screen.Save(file, ImageFormat.Png);
         var fileInfo = new FileInfo(file);
         fileInfo.Refresh();
         fileInfo.CreationTime = testScreenshot.Date;
     }
 }
コード例 #12
0
        public static string Save(this TestScreenshotDto testScreenshot, string path)
        {
            path.Create();
            var fullPath = Path.Combine(path, NamesProvider.GetScreenshotFileName(testScreenshot.TestScreenshotInfo.Date));

            using (var file = File.CreateText(fullPath))
            {
                var serializer = new JsonSerializer();
                serializer.Serialize(file, testScreenshot);
            }
            var fileInfo = new FileInfo(fullPath);

            fileInfo.Refresh();
            fileInfo.CreationTime = testScreenshot.TestScreenshotInfo.Date;
            return(fullPath);
        }
コード例 #13
0
        public static DatabaseEntity <TestScreenshot> Map(this TestScreenshotDto testScreenshotDto)
        {
            var id = $"screenshot-{testScreenshotDto.TestGuid.ToString()}" +
                     $"-{testScreenshotDto.TestScreenshotInfo.Date:yyyyMMdd_HHmmssfff}";
            var testScreenshot = new TestScreenshot
            {
                TestScreenshotInfo = testScreenshotDto.TestScreenshotInfo.MapSimpleItemInfo(id),
                Base64Data         = testScreenshotDto.Base64Data,
                TestGuid           = testScreenshotDto.TestGuid,
                Format             = testScreenshotDto.Format
            };
            var entity = new DatabaseEntity <TestScreenshot>
            {
                Data = testScreenshot,
                Id   = id,
                Type = EntityType.ScreenshotType
            };

            return(entity);
        }
コード例 #14
0
        public SimpleItemInfoDto SaveScreenshot(TestScreenshotDto screenshot)
        {
            screenshot.TestScreenshotInfo.ItemName =
                NamesProvider.GetScreenshotFileName(screenshot.TestScreenshotInfo.Date);
            var testGuid = screenshot.TestGuid;
            var path     = _locationsProvider.GetScreenshotFolderPath(testGuid);

            screenshot.Save(path);
            _logger.Info($"Screenshot was saved: '{path}'");
            _logger.Debug($"Screenshot data was saved correctly: {JsonConvert.SerializeObject(screenshot, Formatting.Indented)}");
            if (_processedTests.ContainsKey(testGuid))
            {
                var testRun = _reader.GetTestRun(_processedTests[testGuid]);
                if (testRun.Screenshots.All(s => s.Date != screenshot.TestScreenshotInfo.Date))
                {
                    testRun.Screenshots.Add(screenshot.TestScreenshotInfo);
                    var output = _reader.GetTestOutput(testRun);
                    SaveTestRun(testRun, output);
                }
            }
            return(screenshot.TestScreenshotInfo);
        }
コード例 #15
0
        public static GhprTestCase GetTestRun(XmlNode testNode, ILogger logger)
        {
            try
            {
                var now         = DateTime.UtcNow;
                var testType    = testNode.SelectSingleNode("properties/property[@name='TestType']")?.Val();
                var priority    = testNode.SelectSingleNode("properties/property[@name='Priority']")?.Val();
                var description = testNode.SelectSingleNode("properties/property[@name='Description']")?.Val();
                var categories  = testNode.SelectNodes("properties/property[@name='Category']")?.Cast <XmlNode>()
                                  .Select(n => n.Val()).ToArray();

                var testDataDateTimes = testNode.SelectNodes(
                    $"properties/property[contains(@name,'{Paths.Names.TestDataDateTimeKeyTemplate}')]")?
                                        .Cast <XmlNode>()
                                        .Select(n => n.Val()).ToList();
                var testDataActuals = testNode.SelectNodes(
                    $"properties/property[contains(@name,'{Paths.Names.TestDataActualKeyTemplate}')]")?
                                      .Cast <XmlNode>()
                                      .Select(n => n.Val()).ToArray();
                var testDataExpecteds = testNode.SelectNodes(
                    $"properties/property[contains(@name,'{Paths.Names.TestDataExpectedKeyTemplate}')]")?
                                        .Cast <XmlNode>()
                                        .Select(n => n.Val()).ToArray();
                var testDataComments = testNode.SelectNodes(
                    $"properties/property[contains(@name,'{Paths.Names.TestDataCommentKeyTemplate}')]")?
                                       .Cast <XmlNode>()
                                       .Select(n => n.Val()).ToArray();
                var testData = new List <TestDataDto>();
                for (var i = 0; i < testDataDateTimes?.Count; i++)
                {
                    testData.Add(new TestDataDto
                    {
                        TestDataInfo = new SimpleItemInfoDto
                        {
                            Date     = DateTime.ParseExact(testDataDateTimes?[i], "yyyyMMdd_HHmmssfff", CultureInfo.InvariantCulture),
                            ItemName = "Test Data"
                        },
                        Actual   = testDataActuals?[i],
                        Expected = testDataExpecteds?[i],
                        Comment  = testDataComments?[i]
                    });
                }
                var r        = testNode.GetAttribute("result");
                var l        = testNode.GetAttribute("label");
                var fullName = testNode.GetAttribute("fullname");
                var testGuid = GetTestGuid(testNode);
                var name     = testNode.GetAttribute("name");
                var duration = double.Parse(testNode.GetAttribute("duration") ?? "0.0", CultureInfo.InvariantCulture);
                var id       = testNode.GetAttribute("id") ?? "";
                var parentId = testNode.GetAttribute("parentId") ?? "";
                if (fullName.Contains(name))
                {
                    var ns = fullName.Substring(0, fullName.LastIndexOf(name, StringComparison.Ordinal) - 1);
                    if (ns.Contains("(") && ns.Contains(")"))
                    {
                        var i1 = ns.IndexOf("(", StringComparison.Ordinal);
                        var i2 = ns.IndexOf(")", StringComparison.Ordinal);
                        ns       = ns.Substring(0, i1) + ns.Substring(i2 + 1);
                        fullName = ns + "." + name;
                    }
                }
                var ti = new ItemInfoDto
                {
                    Guid   = testGuid,
                    Start  = testNode.GetAttribute("start-time", now),
                    Finish = testNode.GetAttribute("end-time", now)
                };
                var test = new TestRunDto
                {
                    Name        = name,
                    FullName    = fullName,
                    Description = description == "null" ? "" : description,
                    Duration    = duration,
                    TestInfo    = ti,
                    TestType    = testType,
                    Priority    = priority,
                    Categories  = categories,
                    Result      = r != null ? (l != null ? $"{r}: {l}" : r) : "Unknown",
                    Output      = new SimpleItemInfoDto
                    {
                        Date     = ti.Finish,
                        ItemName = "Test Output"
                    },
                    TestMessage    = testNode.SelectSingleNode("./failure/message")?.InnerText ?? "",
                    TestStackTrace = testNode.SelectSingleNode("./failure/stack-trace")?.InnerText ?? "",
                    Screenshots    = new List <SimpleItemInfoDto>(),
                    TestData       = testData ?? new List <TestDataDto>()
                };

                var imageAttachments = testNode.SelectNodes(".//attachments/attachment/filePath")?
                                       .Cast <XmlNode>().Select(n => n.InnerText).Where(t => t.EndsWithImgExtension()).ToList();

                var testScreenshots = new List <TestScreenshotDto>();
                foreach (var imageAttachment in imageAttachments.Where(File.Exists))
                {
                    var ext        = Path.GetExtension(imageAttachment);
                    var fileInfo   = new FileInfo(imageAttachment);
                    var bytes      = File.ReadAllBytes(imageAttachment);
                    var base64     = Convert.ToBase64String(bytes);
                    var screenInfo = new SimpleItemInfoDto
                    {
                        Date     = fileInfo.CreationTimeUtc,
                        ItemName = ""
                    };
                    var testScreenshotDto = new TestScreenshotDto
                    {
                        Format             = ext.Replace(".", ""),
                        TestGuid           = testGuid,
                        TestScreenshotInfo = screenInfo,
                        Base64Data         = base64
                    };
                    testScreenshots.Add(testScreenshotDto);
                    test.Screenshots.Add(testScreenshotDto.TestScreenshotInfo);
                }

                var ghprTestCase = new GhprTestCase
                {
                    Id                  = id,
                    ParentId            = parentId,
                    GhprTestRun         = test,
                    GhprTestOutput      = GetTestOutput(testNode, test.TestInfo.Finish, logger),
                    GhprTestScreenshots = testScreenshots
                };

                return(ghprTestCase);
            }
            catch (Exception ex)
            {
                logger.Exception($"Exception in GetTestRun: {ex.Message}{Environment.NewLine}{ex.StackTrace}", ex);
                return(new GhprTestCase());
            }
        }
コード例 #16
0
 public void DeleteTestScreenshot(TestRunDto testRun, TestScreenshotDto testScreenshot)
 {
     throw new NotImplementedException();
 }
コード例 #17
0
 public void DeleteTestScreenshot(TestRunDto testRun, TestScreenshotDto testScreenshot)
 {
 }
コード例 #18
0
 public SimpleItemInfoDto SaveScreenshot(TestScreenshotDto testScreenshot)
 {
     return(new SimpleItemInfoDto {
         Date = DateTime.Now, ItemName = "SaveScreenshot"
     });
 }
コード例 #19
0
        public List <GhprTestCase> GetTestRuns()
        {
            var testRuns         = new List <GhprTestCase>();
            var deploymentFolder = _xml.GetNode("TestSettings")?.GetNode("Deployment")?.GetAttrVal("runDeploymentRoot");
            var utrs             = _xml.GetNodesList("UnitTestResult");
            var uts = _xml.GetNode("TestDefinitions")?.GetNodesList("UnitTest");

            if (utrs == null)
            {
                Console.WriteLine("No tests found!");
                return(testRuns);
            }

            foreach (var utr in utrs)
            {
                try
                {
                    var executionId      = utr.GetAttrVal("executionId");
                    var start            = utr.GetDateTimeVal("startTime");
                    var finish           = utr.GetDateTimeVal("endTime");
                    var duration         = utr.GetAttrVal("duration");
                    var durationTimeSpan = new TimeSpan(0);
                    TimeSpan.TryParse(duration, out durationTimeSpan);
                    var internalTestGuid = utr.GetAttrVal("testId") ?? Guid.NewGuid().ToString();

                    var testName = utr.GetAttrVal("testName");
                    var ut       = uts?.FirstOrDefault(node => (node.GetAttrVal("id") ?? "").Equals(internalTestGuid));

                    if (utr.FirstChild != null && utr.FirstChild.Name.Equals("InnerResults"))
                    {
                        continue;
                    }

                    var tm           = ut?.GetNode("TestMethod");
                    var testDesc     = ut?.GetNode("Description")?.InnerText;
                    var testFullName = (tm?.GetAttrVal("className") ?? "").Split(',')[0] + "." + testName;
                    var testGuid     = testFullName.ToMd5HashGuid();
                    var testInfo     = new ItemInfoDto
                    {
                        Start  = start,
                        Finish = finish,
                        Guid   = testGuid
                    };
                    var result     = utr.GetAttrVal("outcome");
                    var outputNode = utr.GetNode("Output");
                    var output     = outputNode?.GetNode("StdOut")?.InnerText ?? "";
                    var msg        = outputNode?.GetNode("ErrorInfo")?.GetNode("Message")?.InnerText ?? "";
                    var sTrace     = outputNode?.GetNode("ErrorInfo")?.GetNode("StackTrace")?.InnerText ?? "";

                    var testOutputInfo = new SimpleItemInfoDto
                    {
                        Date     = finish,
                        ItemName = "Test output"
                    };

                    var testRun = new TestRunDto
                    {
                        TestInfo       = testInfo,
                        Name           = testName,
                        Description    = testDesc,
                        Duration       = durationTimeSpan == new TimeSpan(0) ? .0 : durationTimeSpan.TotalSeconds,
                        FullName       = testFullName,
                        Result         = result,
                        Output         = testOutputInfo,
                        TestMessage    = msg,
                        TestStackTrace = sTrace
                    };

                    var testOutput = new TestOutputDto
                    {
                        TestOutputInfo = testOutputInfo,
                        Output         = output,
                        SuiteOutput    = ""
                    };

                    var testScreenshots = new List <TestScreenshotDto>();
                    var resFiles        = utr.GetNode("ResultFiles")?.GetNodesList("ResultFile") ?? new List <XmlNode>();
                    foreach (var resFile in resFiles)
                    {
                        var relativePath    = resFile.GetAttrVal("path");
                        var fullResFilePath = Path.Combine(
                            Path.GetDirectoryName(_trxFullPath), deploymentFolder, "In", executionId, relativePath);
                        if (File.Exists(fullResFilePath))
                        {
                            try
                            {
                                var ext = Path.GetExtension(fullResFilePath);
                                if (new[] { "png", "jpg", "jpeg", "bmp" }.Contains(ext.Replace(".", "").ToLower()))
                                {
                                    var fileInfo   = new FileInfo(fullResFilePath);
                                    var bytes      = File.ReadAllBytes(fullResFilePath);
                                    var base64     = Convert.ToBase64String(bytes);
                                    var screenInfo = new SimpleItemInfoDto
                                    {
                                        Date     = fileInfo.CreationTimeUtc,
                                        ItemName = ""
                                    };
                                    var testScreenshotDto = new TestScreenshotDto
                                    {
                                        Format             = ext.Replace(".", ""),
                                        TestGuid           = testGuid,
                                        TestScreenshotInfo = screenInfo,
                                        Base64Data         = base64
                                    };
                                    testScreenshots.Add(testScreenshotDto);
                                    testRun.Screenshots.Add(screenInfo);
                                }
                            }
                            catch (Exception e)
                            {
                                Console.WriteLine($"Error when trying to add test attachment: {e.Message}{Environment.NewLine}" +
                                                  $"{e.StackTrace}{Environment.NewLine}" +
                                                  $"The test XML node is:{Environment.NewLine}" +
                                                  $"{utr.OuterXml}" +
                                                  $"The file path is:{Environment.NewLine}" +
                                                  $"{fullResFilePath}");
                            }
                        }
                    }

                    var ghprTestCase = new GhprTestCase
                    {
                        Id                  = testGuid.ToString(),
                        ParentId            = "",
                        GhprTestRun         = testRun,
                        GhprTestOutput      = testOutput,
                        GhprTestScreenshots = testScreenshots
                    };

                    testRuns.Add(ghprTestCase);
                }
                catch (Exception e)
                {
                    Console.WriteLine($"Error when trying to parse the test: {e.Message}{Environment.NewLine}" +
                                      $"{e.StackTrace}{Environment.NewLine}" +
                                      $"The test XML node is:{Environment.NewLine}" +
                                      $"{utr.OuterXml}");
                }
            }

            return(testRuns);
        }
コード例 #20
0
        public static void Main(string[] args)
        {
            var reporter = ReporterFactory.Build(new DummyTestDataProvider());

            ResourceExtractor.ExtractReportBase(reporter.ReporterSettings.OutputPath);

            reporter.Logger.Info("STARTED");

            var reportSettings = new ReportSettingsDto(5, 7, "Awesome report", "Awesome project");

            reporter.DataWriterService.SaveReportSettings(reportSettings);
            reporter.DataWriterService.SaveReportSettings(reportSettings);
            reporter.DataWriterService.SaveReportSettings(reportSettings);

            var run = new RunDto
            {
                RunInfo = new ItemInfoDto
                {
                    Start  = DateTime.Now.AddMinutes(-2),
                    Finish = DateTime.Now,
                    Guid   = Guid.NewGuid()
                },
                RunSummary = new RunSummaryDto(),
                Name       = "Awesome run",
                Sprint     = "Sprint 1",
                TestsInfo  = new List <ItemInfoDto>()
            };

            reporter.DataWriterService.SaveRun(run);
            reporter.DataWriterService.SaveRun(run);

            reporter.Logger.Info("RUN SAVED");

            var testGuid = Guid.NewGuid();
            var screen   = new TestScreenshotDto
            {
                TestScreenshotInfo = new SimpleItemInfoDto
                {
                    Date     = DateTime.Now,
                    ItemName = "Screenshot"
                },
                Base64Data = "ASDJasdkajasdfas==",
                TestGuid   = testGuid
            };
            var test     = new TestRunDto(testGuid, "Test", "Test.FullName");
            var testInfo = new ItemInfoDto
            {
                Start  = DateTime.Now.AddSeconds(-2),
                Finish = DateTime.Now.AddSeconds(2),
                Guid   = testGuid
            };

            test.TestInfo = testInfo;
            reporter.DataWriterService.SaveScreenshot(screen);
            reporter.DataWriterService.SaveTestRun(test, new TestOutputDto
            {
                TestOutputInfo = new SimpleItemInfoDto
                {
                    Date     = DateTime.Now,
                    ItemName = "Some output"
                },
                Output      = "output",
                SuiteOutput = "suite output"
            });

            reporter.Logger.Info("DONE");
            reporter.TearDown();
        }
コード例 #21
0
 public void DeleteTestScreenshot(TestRunDto testRun, TestScreenshotDto testScreenshot)
 {
     _dataWriterService.DeleteTestScreenshot(testRun, testScreenshot);
     _cache.DeleteTestScreenshot(testRun, testScreenshot);
 }