Exemplo n.º 1
0
        public void MultipleStepsTest()
        {
            _lifecycle = Allure.DefaultLifecycle;
            var tsevt = new TestSuiteStartedEvent(SuiteUid, "suite42");

            _lifecycle.Fire(tsevt);
            var tcsevt = new TestCaseStartedEvent(SuiteUid, "test name");

            _lifecycle.Fire(tcsevt);
            _lifecycle.Fire(new StepStartedEvent("step1"));
            _lifecycle.Fire(new StepFinishedEvent());

            Assert.AreEqual(1, _lifecycle.StepStorage.Get().Last.Value.steps.Length);
            Assert.AreEqual("step1", _lifecycle.StepStorage.Get().Last.Value.steps[0].name);
            Assert.AreEqual(status.passed, _lifecycle.StepStorage.Get().Last.Value.steps[0].status);
            Assert.AreNotEqual(0, _lifecycle.StepStorage.Get().Last.Value.steps[0].stop);

            _lifecycle.Fire(new StepStartedEvent("step2"));
            _lifecycle.Fire(new StepFailureEvent());
            _lifecycle.Fire(new StepFinishedEvent());

            Assert.AreEqual(2, _lifecycle.StepStorage.Get().Last.Value.steps.Length);
            Assert.AreEqual("step2", _lifecycle.StepStorage.Get().Last.Value.steps[1].name);
            Assert.AreEqual(status.broken, _lifecycle.StepStorage.Get().Last.Value.steps[1].status);
            Assert.AreNotEqual(0, _lifecycle.StepStorage.Get().Last.Value.steps[1].stop);

            _lifecycle.Fire(new StepStartedEvent("step3"));
            _lifecycle.Fire(new StepFinishedEvent());

            Assert.AreEqual(3, _lifecycle.StepStorage.Get().Last.Value.steps.Length);
            Assert.AreEqual("step3", _lifecycle.StepStorage.Get().Last.Value.steps[2].name);
            Assert.AreEqual(status.passed, _lifecycle.StepStorage.Get().Last.Value.steps[2].status);
            Assert.AreNotEqual(0, _lifecycle.StepStorage.Get().Last.Value.steps[2].stop);
        }
Exemplo n.º 2
0
        public void StepFinishedEventAfterStepFailureEventTest()
        {
            _lifecycle = Allure.DefaultLifecycle;
            var tsevt = new TestSuiteStartedEvent(SuiteUid, "suite42");

            _lifecycle.Fire(tsevt);
            var tcsevt = new TestCaseStartedEvent(SuiteUid, "test name");

            _lifecycle.Fire(tcsevt);
            var ssevt = new StepStartedEvent("step1");

            _lifecycle.Fire(ssevt);
            var sfevt = new StepFailureEvent
            {
                Throwable = new NullReferenceException("other exception")
            };

            _lifecycle.Fire(sfevt);
            var evt = new StepFinishedEvent();

            _lifecycle.Fire(evt);
            Assert.AreEqual(1, _lifecycle.StepStorage.Get().Last.Value.steps.Length);
            Assert.AreEqual("step1", _lifecycle.StepStorage.Get().Last.Value.steps[0].name);
            Assert.AreEqual(status.broken, _lifecycle.StepStorage.Get().Last.Value.steps[0].status);
            Assert.AreNotEqual(0, _lifecycle.StepStorage.Get().Last.Value.steps[0].stop);
        }
Exemplo n.º 3
0
        public void TestSuiteAttributesTest()
        {
            var evt     = new TestSuiteStartedEvent("1", "testsuite with title");
            var manager = new AttributeManager(new List <Attribute>
            {
                new AllureTitleAttribute("Awesome title"),
                new AllureDescriptionAttribute("Awesome description", descriptiontype.text),
                new AllureSeverityAttribute(severitylevel.critical),
                new AllureFeaturesAttribute("Awesome feature", "Another awesome feature", "Awesome feature2", "New awesome feature"),
                new AllureStoriesAttribute("Awesome story", "Another awesome story", "Awesome story2", "New awesome story")
            });

            manager.Update(evt);
            Assert.AreEqual("Awesome title", evt.Title);
            Assert.AreEqual("Awesome description", evt.Description.Value);
            Assert.AreEqual(descriptiontype.text, evt.Description.type);
            Assert.AreEqual("feature", evt.Labels[0].name);
            Assert.AreEqual("Awesome feature", evt.Labels[0].value);
            Assert.AreEqual("feature", evt.Labels[1].name);
            Assert.AreEqual("Another awesome feature", evt.Labels[1].value);
            Assert.AreEqual("feature", evt.Labels[2].name);
            Assert.AreEqual("Awesome feature2", evt.Labels[2].value);
            Assert.AreEqual("feature", evt.Labels[3].name);
            Assert.AreEqual("New awesome feature", evt.Labels[3].value);
            Assert.AreEqual("story", evt.Labels[4].name);
            Assert.AreEqual("Awesome story", evt.Labels[4].value);
            Assert.AreEqual("story", evt.Labels[5].name);
            Assert.AreEqual("Another awesome story", evt.Labels[5].value);
            Assert.AreEqual("story", evt.Labels[6].name);
            Assert.AreEqual("Awesome story2", evt.Labels[6].value);
            Assert.AreEqual("story", evt.Labels[7].name);
            Assert.AreEqual("New awesome story", evt.Labels[7].value);
        }
Exemplo n.º 4
0
        public override void SuiteStarted(TestName testName)
        {
            try
            {
                string assembly = testName.FullName.Split('.')[0];
                string clazz    = testName.FullName.Split('.')[testName.FullName.Split('.').Count() - 1];

                string suiteUid = Guid.NewGuid().ToString();
                var    evt      = new TestSuiteStartedEvent(suiteUid, testName.FullName);

                foreach (
                    Assembly asm in AppDomain.CurrentDomain.GetAssemblies().Where(x => x.FullName.Contains(assembly)))
                {
                    foreach (Type type in asm.GetTypes().Where(x => x.Name.Contains(clazz)))
                    {
                        var manager = new AttributeManager(type.GetCustomAttributes(false).OfType <Attribute>().ToList());
                        manager.Update(evt);

                        SuiteStorage.Add(testName.FullName, suiteUid);

                        _lifecycle.Fire(evt);

                        return;
                    }
                }
            }
            catch (Exception e)
            {
                Logger.Error(String.Format("Exception in SuiteStarted \"{0}\"", testName), e);
            }
        }
 /// <summary>
 /// Updates TestSuiteStartedEvent based on attributes.
 /// <see cref="AllureCSharpCommons.Attributes"/>
 /// </summary>
 /// <param name="evt"></param>
 public void Update(TestSuiteStartedEvent evt)
 {
     _attributes.ForEach(x =>
     {
         if (x.GetType() == typeof(AllureTitleAttribute))
         {
             var attr  = (AllureTitleAttribute)x;
             evt.Title = attr.Value;
         }
         else if (x.GetType() == typeof(AllureDescriptionAttribute))
         {
             var attr        = (AllureDescriptionAttribute)x;
             evt.Description = attr.Value;
         }
         else if (x.GetType() == typeof(AllureStoriesAttribute))
         {
             var attr   = (AllureStoriesAttribute)x;
             evt.Labels = ArraysUtils.AddLabels(evt.Labels, "story", attr.Stories);
         }
         else if (x.GetType() == typeof(AllureFeaturesAttribute))
         {
             var attr   = (AllureFeaturesAttribute)x;
             evt.Labels = ArraysUtils.AddLabels(evt.Labels, "feature", attr.Features);
         }
     });
 }
        public void MultipleTestCasesTest()
        {
            _lifecycle = Allure.DefaultLifecycle;
            var tsevt = new TestSuiteStartedEvent(SuiteUid, "suite42");

            _lifecycle.Fire(tsevt);

            var evt = new TestCaseStartedEvent(SuiteUid, "test name1");

            _lifecycle.Fire(evt);
            _lifecycle.Fire(new TestCaseCanceledEvent());
            _lifecycle.Fire(new TestCaseFinishedEvent());

            Assert.IsNull(_lifecycle.TestCaseStorage.Value);
            Assert.AreEqual(1, _lifecycle.TestSuiteStorage.Get(SuiteUid).testcases.Length);
            Assert.AreEqual("test name1", _lifecycle.TestSuiteStorage.Get(SuiteUid).testcases[0].name);
            Assert.AreEqual(status.canceled, _lifecycle.TestSuiteStorage.Get(SuiteUid).testcases[0].status);
            Assert.AreEqual("Test skipped with unknown reason",
                            _lifecycle.TestSuiteStorage.Get(SuiteUid).testcases[0].failure.message);
            Assert.AreEqual(null, _lifecycle.TestSuiteStorage.Get(SuiteUid).testcases[0].attachments);
            Assert.AreEqual(null, _lifecycle.TestSuiteStorage.Get(SuiteUid).testcases[0].steps);
            Assert.AreNotEqual(0, _lifecycle.TestSuiteStorage.Get(SuiteUid).testcases[0].stop);

            var evt1 = new TestCaseStartedEvent(SuiteUid, "test name2");

            _lifecycle.Fire(evt1);
            _lifecycle.Fire(new TestCasePendingEvent());
            _lifecycle.Fire(new TestCaseFinishedEvent());

            Assert.IsNull(_lifecycle.TestCaseStorage.Value);
            Assert.AreEqual(2, _lifecycle.TestSuiteStorage.Get(SuiteUid).testcases.Length);
            Assert.AreEqual("test name2", _lifecycle.TestSuiteStorage.Get(SuiteUid).testcases[1].name);
            Assert.AreEqual(status.pending, _lifecycle.TestSuiteStorage.Get(SuiteUid).testcases[1].status);
            Assert.AreEqual("Test not implemented yet",
                            _lifecycle.TestSuiteStorage.Get(SuiteUid).testcases[1].failure.message);
            Assert.AreEqual(null, _lifecycle.TestSuiteStorage.Get(SuiteUid).testcases[1].attachments);
            Assert.AreEqual(null, _lifecycle.TestSuiteStorage.Get(SuiteUid).testcases[1].steps);
            Assert.AreNotEqual(0, _lifecycle.TestSuiteStorage.Get(SuiteUid).testcases[1].stop);

            var evt2 = new TestCaseStartedEvent(SuiteUid, "test name3");

            _lifecycle.Fire(evt2);
            _lifecycle.Fire(new TestCaseFailureEvent());
            _lifecycle.Fire(new TestCaseFinishedEvent());

            Assert.IsNull(_lifecycle.TestCaseStorage.Value);
            Assert.AreEqual(3, _lifecycle.TestSuiteStorage.Get(SuiteUid).testcases.Length);
            Assert.AreEqual("test name3", _lifecycle.TestSuiteStorage.Get(SuiteUid).testcases[2].name);
            Assert.AreEqual(status.broken, _lifecycle.TestSuiteStorage.Get(SuiteUid).testcases[2].status);
            Assert.AreEqual("Test broken with unknown reason",
                            _lifecycle.TestSuiteStorage.Get(SuiteUid).testcases[2].failure.message);
            Assert.AreEqual(null, _lifecycle.TestSuiteStorage.Get(SuiteUid).testcases[2].attachments);
            Assert.AreEqual(null, _lifecycle.TestSuiteStorage.Get(SuiteUid).testcases[2].steps);
            Assert.AreNotEqual(0, _lifecycle.TestSuiteStorage.Get(SuiteUid).testcases[2].stop);
        }
        public void SuiteStartedEventTest()
        {
            _lifecycle = Allure.DefaultLifecycle;
            var evt = new TestSuiteStartedEvent(SuiteUid, "suite42");

            _lifecycle.Fire(evt);
            Assert.AreEqual(1, _lifecycle.TestSuiteStorage.Map.Count);
            Assert.True(_lifecycle.TestSuiteStorage.Map.ContainsKey(SuiteUid));
            Assert.AreEqual(null, _lifecycle.TestSuiteStorage.Get(SuiteUid).testcases);
            Assert.AreEqual("suite42", _lifecycle.TestSuiteStorage.Get(SuiteUid).name);
        }
Exemplo n.º 8
0
        public void TestSuiteTitleAttributeTest()
        {
            var evt     = new TestSuiteStartedEvent("1", "testsuite with title");
            var manager = new AttributeManager(new List <Attribute>
            {
                new AllureTitleAttribute("Awesome title")
            });

            manager.Update(evt);
            Assert.AreEqual("Awesome title", evt.Title);
        }
Exemplo n.º 9
0
        public void TestSuiteSeverityAttributeTest()
        {
            var evt     = new TestSuiteStartedEvent("1", "testsuite with severity");
            var manager = new AttributeManager(new List <Attribute>
            {
                new AllureSeverityAttribute(severitylevel.critical)
            });

            manager.Update(evt);
            Assert.IsNull(evt.Labels);
        }
Exemplo n.º 10
0
        public void TestSuiteDescriptionAttributeTest()
        {
            var evt     = new TestSuiteStartedEvent("1", "testsuite with description");
            var manager = new AttributeManager(new List <Attribute>
            {
                new AllureDescriptionAttribute("Awesome description", descriptiontype.text)
            });

            manager.Update(evt);
            Assert.AreEqual("Awesome description", evt.Description.Value);
            Assert.AreEqual(descriptiontype.text, evt.Description.type);
        }
        public void SuiteFinishedTest()
        {
            _lifecycle = Allure.DefaultLifecycle;
            var tsevt = new TestSuiteStartedEvent(SuiteUid, "suite42");

            _lifecycle.Fire(tsevt);
            var tfevt = new TestSuiteFinishedEvent(SuiteUid);

            _lifecycle.Fire(tfevt);
            Assert.AreEqual(0, _lifecycle.TestSuiteStorage.Map.Count);
            Assert.False(_lifecycle.TestSuiteStorage.Map.ContainsKey(SuiteUid));
        }
Exemplo n.º 12
0
        public void TestSuiteStroiesAttributeTest()
        {
            var evt     = new TestSuiteStartedEvent("1", "testsuite with title");
            var manager = new AttributeManager(new List <Attribute>
            {
                new AllureStoriesAttribute("Awesome story")
            });

            manager.Update(evt);
            Assert.AreEqual("story", evt.Labels[0].name);
            Assert.AreEqual("Awesome story", evt.Labels[0].value);
        }
Exemplo n.º 13
0
 public void StartSuite(FeatureInfo featureInfo)
 {
     if (featureInfo != null)
     {
         var uid          = GetTestSuiteIdForCurrentThread(featureInfo);
         var suiteStarted = new TestSuiteStartedEvent(uid, uid);
         suiteStarted.Title       = featureInfo.Title;
         suiteStarted.Description = new description {
             type = descriptiontype.text, Value = featureInfo.Description
         };
         suiteStarted.Labels = GetFeatureLabels(featureInfo);
         lifecycle.Fire(suiteStarted);
     }
 }
        public void TestCaseFailureWithoutExceptionEventTest()
        {
            _lifecycle = Allure.DefaultLifecycle;
            var tsevt = new TestSuiteStartedEvent(SuiteUid, "suite42");

            _lifecycle.Fire(tsevt);
            var tcsevt = new TestCaseStartedEvent(SuiteUid, "test name");

            _lifecycle.Fire(tcsevt);
            var evt = new TestCaseFailureEvent();

            _lifecycle.Fire(evt);
            Assert.AreEqual(status.broken, _lifecycle.TestSuiteStorage.Get(SuiteUid).testcases[0].status);
            Assert.AreEqual("Test broken with unknown reason",
                            _lifecycle.TestSuiteStorage.Get(SuiteUid).testcases[0].failure.message);
        }
        public void TestCaseCanceledEventTest()
        {
            _lifecycle = Allure.DefaultLifecycle;
            var tsevt = new TestSuiteStartedEvent(SuiteUid, "suite42");

            _lifecycle.Fire(tsevt);
            var tcsevt = new TestCaseStartedEvent(SuiteUid, "test name");

            _lifecycle.Fire(tcsevt);
            var evt = new TestCaseCanceledEvent();

            _lifecycle.Fire(evt);
            Assert.AreEqual(status.canceled, _lifecycle.TestSuiteStorage.Get(SuiteUid).testcases[0].status);
            Assert.AreEqual("Test skipped with unknown reason",
                            _lifecycle.TestSuiteStorage.Get(SuiteUid).testcases[0].failure.message);
        }
        public void TestCaseStartedEventTest()
        {
            _lifecycle = Allure.DefaultLifecycle;
            var tsevt = new TestSuiteStartedEvent(SuiteUid, "suite42");

            _lifecycle.Fire(tsevt);
            var evt = new TestCaseStartedEvent(SuiteUid, "test name");

            _lifecycle.Fire(evt);
            Assert.AreEqual(true, _lifecycle.TestCaseStorage.IsValueCreated);
            Assert.AreEqual("test name", _lifecycle.TestSuiteStorage.Get(SuiteUid).testcases[0].name);
            Assert.AreEqual(status.passed, _lifecycle.TestSuiteStorage.Get(SuiteUid).testcases[0].status);
            Assert.IsNull(_lifecycle.TestSuiteStorage.Get(SuiteUid).testcases[0].steps);
            Assert.AreNotEqual(0, _lifecycle.TestSuiteStorage.Get(SuiteUid).testcases[0].start);
            Assert.AreEqual(0, _lifecycle.TestSuiteStorage.Get(SuiteUid).testcases[0].stop);
        }
        public void TestCasePendingEventWithoutMessageWithoutExceptionTest()
        {
            _lifecycle = Allure.DefaultLifecycle;
            var tsevt = new TestSuiteStartedEvent(SuiteUid, "suite42");

            _lifecycle.Fire(tsevt);
            var tcsevt = new TestCaseStartedEvent(SuiteUid, "test name");

            _lifecycle.Fire(tcsevt);
            var evt = new TestCasePendingEvent();

            _lifecycle.Fire(evt);
            Assert.AreEqual(status.pending, _lifecycle.TestSuiteStorage.Get(SuiteUid).testcases[0].status);
            Assert.AreEqual("Test not implemented yet",
                            _lifecycle.TestSuiteStorage.Get(SuiteUid).testcases[0].failure.message);
            Assert.IsNull(_lifecycle.TestSuiteStorage.Get(SuiteUid).testcases[0].failure.stacktrace);
        }
Exemplo n.º 18
0
        public void StepStartedEventTest()
        {
            _lifecycle = Allure.DefaultLifecycle;
            var tsevt = new TestSuiteStartedEvent(SuiteUid, "suite42");

            _lifecycle.Fire(tsevt);
            var tcsevt = new TestCaseStartedEvent(SuiteUid, "test name");

            _lifecycle.Fire(tcsevt);
            var evt = new StepStartedEvent("step1");

            _lifecycle.Fire(evt);
            Assert.AreEqual(2, _lifecycle.StepStorage.Get().Count); //Root step + step1
            Assert.AreEqual("step1", _lifecycle.StepStorage.Get().Last.Value.name);
            Assert.AreNotEqual(0, _lifecycle.StepStorage.Get().Last.Value.start);
            Assert.AreEqual(0, _lifecycle.StepStorage.Get().Last.Value.stop);
        }
        public void TestCaseFailureWithOtherExceptionEventTest()
        {
            _lifecycle = Allure.DefaultLifecycle;
            var tsevt = new TestSuiteStartedEvent(SuiteUid, "suite42");

            _lifecycle.Fire(tsevt);
            var tcsevt = new TestCaseStartedEvent(SuiteUid, "test name");

            _lifecycle.Fire(tcsevt);
            var evt = new TestCaseFailureEvent
            {
                Throwable = new NullReferenceException("null reference exception")
            };

            _lifecycle.Fire(evt);
            Assert.AreEqual(status.broken, _lifecycle.TestSuiteStorage.Get(SuiteUid).testcases[0].status);
            Assert.AreEqual("null reference exception",
                            _lifecycle.TestSuiteStorage.Get(SuiteUid).testcases[0].failure.message);
        }
        public void TestCaseFinishedEventTest()
        {
            _lifecycle = Allure.DefaultLifecycle;
            var tsevt = new TestSuiteStartedEvent(SuiteUid, "suite42");

            _lifecycle.Fire(tsevt);
            var tcsevt = new TestCaseStartedEvent(SuiteUid, "test name");

            _lifecycle.Fire(tcsevt);
            var evt = new TestCaseFinishedEvent();

            _lifecycle.Fire(evt);
            Assert.IsNull(_lifecycle.TestCaseStorage.Value);
            Assert.AreEqual(1, _lifecycle.TestSuiteStorage.Get(SuiteUid).testcases.Length);
            Assert.AreEqual("test name", _lifecycle.TestSuiteStorage.Get(SuiteUid).testcases[0].name);
            Assert.AreEqual(null, _lifecycle.TestSuiteStorage.Get(SuiteUid).testcases[0].failure);
            Assert.AreEqual(null, _lifecycle.TestSuiteStorage.Get(SuiteUid).testcases[0].attachments);
            Assert.AreEqual(null, _lifecycle.TestSuiteStorage.Get(SuiteUid).testcases[0].steps);
            Assert.AreNotEqual(0, _lifecycle.TestSuiteStorage.Get(SuiteUid).testcases[0].stop);
        }
Exemplo n.º 21
0
        public void StepFinishedEventTest()
        {
            _lifecycle = Allure.DefaultLifecycle;
            var tsevt = new TestSuiteStartedEvent(SuiteUid, "suite42");

            _lifecycle.Fire(tsevt);
            var tcsevt = new TestCaseStartedEvent(SuiteUid, "test name");

            _lifecycle.Fire(tcsevt);
            var ssevt = new StepStartedEvent("step1");

            _lifecycle.Fire(ssevt);
            var evt = new StepFinishedEvent();

            _lifecycle.Fire(evt);
            Assert.AreEqual(1, _lifecycle.StepStorage.Get().Last.Value.steps.Length);
            Assert.AreEqual("step1", _lifecycle.StepStorage.Get().Last.Value.steps[0].name);
            Assert.AreEqual(status.passed, _lifecycle.StepStorage.Get().Last.Value.steps[0].status);
            Assert.AreNotEqual(0, _lifecycle.StepStorage.Get().Last.Value.steps[0].stop);
        }
        public void TestCasePendingEventWithoutMessageWithExceptionTest()
        {
            _lifecycle = Allure.DefaultLifecycle;
            var tsevt = new TestSuiteStartedEvent(SuiteUid, "suite42");

            _lifecycle.Fire(tsevt);
            var tcsevt = new TestCaseStartedEvent(SuiteUid, "test name");

            _lifecycle.Fire(tcsevt);
            var evt = new TestCasePendingEvent
            {
                Throwable = new Exception("exception")
            };

            _lifecycle.Fire(evt);
            Assert.AreEqual(status.pending, _lifecycle.TestSuiteStorage.Get(SuiteUid).testcases[0].status);
            Assert.AreEqual("exception", _lifecycle.TestSuiteStorage.Get(SuiteUid).testcases[0].failure.message);
            Assert.AreEqual("There is no stack trace",
                            _lifecycle.TestSuiteStorage.Get(SuiteUid).testcases[0].failure.stacktrace);
        }
Exemplo n.º 23
0
        public void StepFailureEventWithOtherExceptionTest()
        {
            _lifecycle = Allure.DefaultLifecycle;
            var tsevt = new TestSuiteStartedEvent(SuiteUid, "suite42");

            _lifecycle.Fire(tsevt);
            var tcsevt = new TestCaseStartedEvent(SuiteUid, "test name");

            _lifecycle.Fire(tcsevt);
            var ssevt = new StepStartedEvent("step1");

            _lifecycle.Fire(ssevt);
            var evt = new StepFailureEvent
            {
                Throwable = new NullReferenceException("other exception")
            };

            _lifecycle.Fire(evt);
            Assert.AreEqual(2, _lifecycle.StepStorage.Get().Count); //Root step + step1
            Assert.AreEqual(status.broken, _lifecycle.StepStorage.Get().Last.Value.status);
        }
        public void TestCaseFailureWithAssertionExceptionAndStackTraceEventTest()
        {
            _lifecycle = Allure.DefaultLifecycle;
            var tsevt = new TestSuiteStartedEvent(SuiteUid, "suite42");

            _lifecycle.Fire(tsevt);
            var tcsevt = new TestCaseStartedEvent(SuiteUid, "test name");

            _lifecycle.Fire(tcsevt);
            var evt = new TestCaseFailureEvent
            {
                Throwable  = new AssertionException("assertion exception"),
                StackTrace = "stack trace"
            };

            _lifecycle.Fire(evt);
            Assert.AreEqual(status.failed, _lifecycle.TestSuiteStorage.Get(SuiteUid).testcases[0].status);
            Assert.AreEqual("assertion exception",
                            _lifecycle.TestSuiteStorage.Get(SuiteUid).testcases[0].failure.message);
            Assert.AreEqual("stack trace",
                            _lifecycle.TestSuiteStorage.Get(SuiteUid).testcases[0].failure.stacktrace);
        }
Exemplo n.º 25
0
        public void OnTestEvent(string report)
        {
            Logger.Info($"{report}");

            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.LoadXml(report);
            var eventType = xmlDoc.DocumentElement;

            using (StreamWriter file =
                       new StreamWriter("WriteLines2.txt", true))
            {
                file.WriteLine(report);
            }
            switch (eventType.Name)
            {
            case "start-suite":
                //Console.WriteLine($"***test-run started: {eventType.InnerText}");
                var suiteFullName = eventType.GetAttribute("name");
                //var suiteFullName = eventType.GetAttribute("fullname");
                //var suiteID = eventType.GetAttribute("id");
                string suiteUid = Guid.NewGuid().ToString();

                string assembly = suiteFullName.Split('.')[0];
                string clazz    = suiteFullName.Split('.')[suiteFullName.Split('.').Length - 1];

                var testSuiteStartedEvt = new TestSuiteStartedEvent(suiteUid, suiteFullName);

                foreach (
                    Assembly asm in AppDomain.CurrentDomain.GetAssemblies().Where(x => x.FullName.Contains(assembly)))
                {
                    foreach (Type type in asm.GetTypes().Where(x => x.Name.Contains(clazz)))
                    {
                        var manager = new AttributeManager(type.GetCustomAttributes(false).OfType <Attribute>().ToList());
                        manager.Update(testSuiteStartedEvt);
                    }
                }
                Logger.Info($"Adding suite '{suiteFullName}' with '{suiteUid}' to SuiteStorage");
                SuiteStorage.Add(suiteFullName, suiteUid);
                _lifecycle.Fire(testSuiteStartedEvt);
                break;

            case "start-test":

                try
                {
                    //Console.WriteLine($"***test started: {eventType.GetAttribute("name")}, id: {eventType.GetAttribute("id")}, parentId: {eventType.GetAttribute("parentId")}");
                    var testFullName = eventType.GetAttribute("fullname");
                    var testName     = eventType.GetAttribute("name");


                    string assembly2 = testFullName.Split('.')[0];
                    string clazz2    = testFullName.Split('(')[0].Split('.')[testFullName.Split('(')[0].Split('.').Count() - 2];

                    var testStartedEvt = new TestCaseStartedEvent((string)SuiteStorage[SuiteStorage.Count - 1], testFullName);

                    foreach (
                        Assembly asm in AppDomain.CurrentDomain.GetAssemblies().Where(x => x.FullName.Contains(assembly2)))
                    {
                        foreach (Type type in asm.GetTypes().Where(x => x.Name.Contains(clazz2)))
                        {
                            string name = !testName.Contains("(")
                                    ? testName
                                    : testName.Substring(0, testName.IndexOf('('));

                            MethodInfo methodInfo = type.GetMethod(name);
                            if (methodInfo == null)
                            {
                                continue;
                            }
                            var manager =
                                new AttributeManager(methodInfo.GetCustomAttributes(false).OfType <Attribute>().ToList());
                            manager.Update(testStartedEvt);
                        }
                    }

                    _lifecycle.Fire(testStartedEvt);
                }
                catch (Exception ex)
                {
                    Logger.Error($"{ex.Message} - {ex.StackTrace}");
                }



                break;

            case "test-case":
                switch (eventType.GetAttribute("result"))
                {
                case "Passed":
                    Logger.Info($"Test Passed: {eventType.GetAttribute("name")}");
                    var testFinishedEvt = new TestCaseFinishedEvent();
                    _lifecycle.Fire(testFinishedEvt);
                    break;

                case "Failed":
                {
                    Logger.Info($"Test Failed: {eventType.GetAttribute("name")}");
                    try
                    {
                        _lifecycle.Fire(new TestCaseFailureEvent
                            {
                                Throwable  = new Exception(eventType["failure"]?["message"]?.InnerText),
                                StackTrace = eventType["failure"]?["stack-trace"]?.InnerText
                            });
                        _lifecycle.Fire(new TestCaseFinishedEvent());
                    }
                    catch (Exception ex)
                    {
                        Logger.Error($"{ex.Message} - {ex.StackTrace}");
                    }
                }
                break;
                }
                break;

            case "test-suite":
                var suiteFullName2      = eventType.GetAttribute("name");
                var suiteUidFromStorage = (string)SuiteStorage[suiteFullName2];
                if (suiteUidFromStorage != null)
                {
                    var testSuiteFinishedEvt = new TestSuiteFinishedEvent(suiteUidFromStorage);
                    try
                    {
                        _lifecycle.Fire(testSuiteFinishedEvt);
                    }
                    catch (Exception ex)
                    {
                        Logger.Error($"{ex.Message} - {ex.StackTrace}");
                    }

                    SuiteStorage.Remove(suiteFullName2);
                }
                else
                {
                    Logger.Warn($"{suiteFullName2} - suite not present in storage");
                }
                break;

            default:

                break;
            }
        }