Ejemplo n.º 1
0
        public void BaseTearDown()
        {
            if (TestContext.CurrentContext.Result.Outcome.Status == TestStatus.Failed)
            {
                AllureResultsUtils.TakeScreenShot(TestContext.CurrentContext.Test.Name);
                AllureLifecycle.Instance.AddAttachment("Screenshot", "image/png", $"{TestContext.CurrentContext.Test.Name}_screenshot.png");
            }

            DriverProvider.CleanupDriver();
        }
Ejemplo n.º 2
0
 private void TakeScreenshot()
 {
     _lifecycle.Fire(new MakeAttachmentEvent(AllureResultsUtils.TakeScreenShot(), "Screenshot", "image/png"));
 }
 public MakeAttachEvent(byte[] attachment, string title, string type)
 {
     Title          = title;
     AttachmentType = type;
     Attach         = AllureResultsUtils.WriteAttachmentSafely(attachment, title, type);
 }
        public override void Process(testcaseresult context)
        {
            var attachment = AllureResultsUtils.WriteAttachmentSafely(Attachment, Title, Type);

            context.attachments = ArraysUtils.Add(context.attachments, attachment);
        }
Ejemplo n.º 5
0
        public void IntegrationTest()
        {
            _lifecycle = Allure.DefaultLifecycle;
            _lifecycle.Fire(new TestSuiteStartedEvent(SuiteUid, "suite42"));

            _lifecycle.Fire(new TestCaseStartedEvent(SuiteUid, "test case"));
            _lifecycle.Fire(new StepStartedEvent("step1"));
            _lifecycle.Fire(new StepFinishedEvent());
            _lifecycle.Fire(new StepStartedEvent("broken step"));
            _lifecycle.Fire(new StepFailureEvent());
            _lifecycle.Fire(new StepFinishedEvent());
            _lifecycle.Fire(new StepStartedEvent("step with attachment"));
            _lifecycle.Fire(new MakeAttachmentEvent(File.ReadAllBytes("TestData/attachment.xml"),
                                                    "XmlAttachment",
                                                    "application/xml"));
            _lifecycle.Fire(new StepFinishedEvent());
            _lifecycle.Fire(new TestCaseFinishedEvent());

            _lifecycle.Fire(new TestCaseStartedEvent(SuiteUid, "test case"));
            _lifecycle.Fire(new TestCasePendingEvent());
            _lifecycle.Fire(new StepStartedEvent("step2"));
            _lifecycle.Fire(new StepFinishedEvent());
            _lifecycle.Fire(new StepStartedEvent("failed step"));
            _lifecycle.Fire(new StepFailureEvent
            {
                Throwable = new AssertionException("assertion exception")
            });
            _lifecycle.Fire(new StepFinishedEvent());
            _lifecycle.Fire(new StepStartedEvent("step with attachment"));
            _lifecycle.Fire(new MakeAttachmentEvent(File.ReadAllBytes("TestData/attachment.json"),
                                                    "JsonAttachment",
                                                    "application/json"));
            _lifecycle.Fire(new MakeAttachmentEvent(AllureResultsUtils.TakeScreenShot(),
                                                    "Screenshot",
                                                    "image/png"));
            _lifecycle.Fire(new StepFinishedEvent());
            _lifecycle.Fire(new TestCaseFinishedEvent());

            _lifecycle.Fire(new TestCaseStartedEvent(SuiteUid, "failing test case"));
            _lifecycle.Fire(new TestCaseFailureEvent());
            _lifecycle.Fire(new TestCaseFinishedEvent());

            _lifecycle.Fire(new TestCaseStartedEvent(SuiteUid, "failing test case2"));
            _lifecycle.Fire(new TestCaseFailureEvent
            {
                Throwable  = new AssertionException("assertion exception"),
                StackTrace = "at com.example.myproject.Book.getTitle(Book.java:16)" +
                             "at com.example.myproject.Author.getBookTitles(Author.java:25)" +
                             "at com.example.myproject.Bootstrap.main(Bootstrap.java:14)"
            });
            _lifecycle.Fire(new TestCaseFinishedEvent());

            _lifecycle.Fire(new TestCaseStartedEvent(SuiteUid, "pending test case"));
            _lifecycle.Fire(new TestCasePendingEvent
            {
                Throwable  = new NullReferenceException(),
                StackTrace = "в System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)" +
                             "в System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelAsyncRequest.CompleteGetResponse(IAsyncResult result)"
            });
            _lifecycle.Fire(new TestCaseFinishedEvent());

            _lifecycle.Fire(new TestCaseStartedEvent(SuiteUid, "pending test case 2"));
            _lifecycle.Fire(new TestCasePendingEvent());
            _lifecycle.Fire(new TestCaseFinishedEvent());

            _lifecycle.Fire(new TestCaseStartedEvent(SuiteUid, "canceled test case"));
            _lifecycle.Fire(new TestCaseCanceledEvent());
            _lifecycle.Fire(new TestCaseFinishedEvent());

            _lifecycle.Fire(new TestSuiteFinishedEvent(SuiteUid));
        }