Example #1
0
        public void TestSuiteStorageTest()
        {
            var storage = new TestSuiteStorage();

            storage.Put("uid");
            Assert.IsFalse(storage.Put("uid"));

            var testsuiteresult = storage.Get("uid");

            Assert.IsNull(testsuiteresult.name);
            Assert.IsNull(testsuiteresult.testcases);
            Assert.AreEqual(0, testsuiteresult.start);
            Assert.AreEqual(0, testsuiteresult.stop);
        }
Example #2
0
        /// <summary>
        /// Processes all testcase events.
        /// <see cref="AllureCSharpCommons.Events.TestCaseStartedEvent"/>
        /// <see cref="AllureCSharpCommons.Events.TestCasePendingEvent"/>
        /// <see cref="AllureCSharpCommons.Events.TestCaseCanceledEvent"/>
        /// <see cref="AllureCSharpCommons.Events.TestCaseFinishedEvent"/>
        /// </summary>
        /// <param name="evt">event to process</param>
        public void Fire(ITestCaseEvent evt)
        {
            if (typeof(TestCaseStartedEvent).IsAssignableFrom(evt.GetType()))
            {
                StepStorage.Get();

                var testcaseresult = TestCaseStorage.Get();
                evt.Process(testcaseresult);

                lock (TestSuiteAddChildLock)
                {
                    TestSuiteStorage.Put(evt.SuiteUid);
                    TestSuiteStorage.Get(evt.SuiteUid).testcases =
                        ArraysUtils.Add(TestSuiteStorage.Get(evt.SuiteUid).testcases, testcaseresult);
                }
            }
            else if (typeof(TestCaseFinishedEvent).IsAssignableFrom(evt.GetType()))
            {
                var testcaseresult = TestCaseStorage.Get();
                evt.Process(testcaseresult);

                var root = StepStorage.PollLast();

                testcaseresult.steps       = ArraysUtils.AddAll(testcaseresult.steps, root.steps);
                testcaseresult.attachments = ArraysUtils.AddAll(testcaseresult.attachments, root.attachments);
                StepStorage.Remove();
                TestCaseStorage.Remove();
            }
            else
            {
                var testcaseresult = TestCaseStorage.Get();
                evt.Process(testcaseresult);
            }
        }
Example #3
0
        /// <summary>
        /// Processes all testsuite events.
        /// When processes TestSuiteFinishedEvent serializes it to xml file.
        /// <see cref="AllureCSharpCommons.Events.TestSuiteStartedEvent"/>
        /// <see cref="AllureCSharpCommons.Events.TestSuiteFinishedEvent"/>
        /// </summary>
        /// <param name="evt">event to process</param>
        public void Fire(ITestSuiteEvent evt)
        {
            if (typeof(TestSuiteFinishedEvent).IsAssignableFrom(evt.GetType()))
            {
                var suiteUid        = evt.Uid;
                var testsuiteresult = TestSuiteStorage.Get(suiteUid);

                if (AllureConfig.AllowEmptySuites ||
                    (testsuiteresult.testcases != null && testsuiteresult.testcases.Length > 0))
                {
                    evt.Process(testsuiteresult);
                    testsuiteresult.SaveToFile(AllureResultsUtils.TestSuitePath);
                }

                TestSuiteStorage.Remove(suiteUid);
            }
            else
            {
                TestSuiteStorage.Put(evt.Uid);
                var testsuiteresult = TestSuiteStorage.Get(evt.Uid);
                evt.Process(testsuiteresult);
            }
        }