Ejemplo n.º 1
0
        public void AfterTest()
        {
            Browser.GetInstance().Quit();
            var nunitTest = TestExecutionContext.CurrentContext.CurrentTest;

            AttachTestLog(nunitTest.Id);
            Allure.UpdateTestCase(nunitTest.Id, x =>
            {
                x.statusDetails = new StatusDetails
                {
                    message = TestContext.CurrentContext.Result.Message,
                    trace   = TestContext.CurrentContext.Result.StackTrace
                };
                x.status = GetNunitStatus(TestContext.CurrentContext.Result.Outcome);
                x.attachments.AddRange(AllureHelper.GetAttaches());
            });

            Allure.StopTestCase(nunitTest.Id);
            Allure.WriteTestCase(nunitTest.Id);
        }
Ejemplo n.º 2
0
        public void Step(string name, Action action)
        {
            var caseId = TestExecutionContext.CurrentContext.CurrentTest.Id;
            var uuid   = Guid.NewGuid().ToString("N");

            Allure.StartStep(caseId, uuid, new StepResult()
            {
                name = name
            });

            int       logLength     = TestExecutionContext.CurrentContext.CurrentResult.Output.Length;
            Exception stepException = null;

            try
            {
                action();
            }
            catch (Exception e)
            {
                stepException = e;
                AllureHelper.AttachPng("FailedElement", File.ReadAllBytes(new DirectoryInfo(FileProvider.GetFailedScreensDirectory())
                                                                          .GetFiles().OrderByDescending(file => file.LastWriteTime).First().FullName));
                AllureHelper.AttachPng("Screenshot",
                                       File.ReadAllBytes(ScreenshotProvider.PublishScreenshot($"Screenshot_{DateTime.Now.ToFileTime()}")));
                throw;
            }
            finally
            {
                Allure.UpdateStep(uuid, x =>
                {
                    x.status        = GetStatusFromException(stepException);
                    x.statusDetails = new StatusDetails
                    {
                        message = stepException?.Message,
                        trace   = stepException?.StackTrace
                    };
                    x.attachments.AddRange(AllureHelper.GetAttaches());
                });
                Allure.StopStep(uuid);
            }
        }