Example #1
0
            /// <summary>
            /// Adds a WriteLine to the next result to be processed.
            /// </summary>
            /// <param name="line">The text to output.</param>
            public void AddPendingWriteLine(string line)
            {
                SimpleXElement xe = CreateElement("StdOut");

                xe.SetValue(line);
                AddPendingOutput(xe);
            }
Example #2
0
            /// <summary>
            /// Adds pending output for the next result.
            /// </summary>
            /// <param name="element">The element to wrap in an Output element.</param>
            private void AddPendingOutput(SimpleXElement element)
            {
                SimpleXElement output = CreateElement("Output");

                output.Add(element);
                _pendingElements.Add(output);
            }
Example #3
0
            /// <summary>
            /// Creates the initial results document and its XElements.
            /// </summary>
            private void CreateInitialDocument()
            {
                TestRun = CreateElement("TestRun");

                TestRunConfiguration = CreateElement("TestSettings");
                TestRun.Add(TestRunConfiguration);

                ResultSummary = CreateElement("ResultSummary");
                Counters      = CreateElement("Counters");
                ResultSummary.Add(Counters);
                TestRun.Add(ResultSummary);

                Times = CreateElement("Times");
                TestRun.Add(Times);

                TestDefinitions = CreateElement("TestDefinitions");
                TestRun.Add(TestDefinitions);

                TestLists = CreateElement("TestLists");
                TestRun.Add(TestLists);

                TestEntries = CreateElement("TestEntries");
                TestRun.Add(TestEntries);

                Results = CreateElement("Results");
                TestRun.Add(Results);

                RunOutcome = TestOutcome.NotExecuted;
            }
Example #4
0
            /// <summary>
            /// Adds an error message to the next result to be processed.
            /// </summary>
            /// <param name="message">The message.</param>
            public void AddPendingErrorMessage(string message)
            {
                SimpleXElement ei = CreateElement("ErrorInfo");
                SimpleXElement me = CreateElement("Message");

                me.SetValue(message);
                ei.Add(me);
                AddPendingOutput(ei);
            }
Example #5
0
            /// <summary>
            /// Adds an Exception to the next result to be processed.
            /// </summary>
            /// <param name="e">The Exception object.</param>
            public void AddPendingException(Exception e)
            {
                SimpleXElement ei = CreateElement("ErrorInfo");
                SimpleXElement me = CreateElement("Message");

                me.SetValue(e.Message);
                ei.Add(me);

                if (!string.IsNullOrEmpty(e.StackTrace))
                {
                    SimpleXElement st = CreateElement("StackTrace");
                    st.SetValue(e.StackTrace);
                    ei.Add(st);
                }

                AddPendingOutput(ei);
            }
Example #6
0
            /// <summary>
            /// Stores property values in the respective elements, clears any
            /// lookup dictionaries.
            /// </summary>
            private void FinalizeContent()
            {
                Times.SetAttributeValue("creation", ToDateString(Created));
                Times.SetAttributeValue("queuing", ToDateString(Created));
                Times.SetAttributeValue("start", ToDateString(Started));
                Times.SetAttributeValue("finish", ToDateString(Finished));

                // Create test lists
                foreach (string list in _testLists.Keys)
                {
                    SimpleXElement test = CreateElement("TestList");
                    test.SetAttributeValue("name", list);
                    test.SetAttributeValue("id", _testLists[list].ToString());
                    TestLists.Add(test);
                }

                // Reclaim some of the memory used for element lookups
                _testLists.Clear();
            }
Example #7
0
            /// <summary>
            /// Adds the result of a test method into the log.
            /// </summary>
            /// <param name="test">The test metadata.</param>
            /// <param name="storage">The storage value.</param>
            /// <param name="codeBase">The code base value.</param>
            /// <param name="adapterTypeName">The adapter type name.</param>
            /// <param name="className">The class name.</param>
            /// <param name="testListName">The test list name.</param>
            /// <param name="computerName">The computer name.</param>
            /// <param name="startTime">The start time.</param>
            /// <param name="endTime">The end time.</param>
            /// <param name="outcome">The outcome.</param>
            public void AddTestMethodResult(
                ITestMethod test,
                string storage,
                string codeBase,
                string adapterTypeName,
                string className,
                string testListName,
                string computerName,
                DateTime startTime,
                DateTime endTime,
                TestOutcome outcome)
            {
                if (test == null)
                {
                    throw new ArgumentNullException("test");
                }

                // Friendly name of the test
                string name = test.Name;

                // Generate GUIDs.
                string testId      = Guid.NewGuid().ToString();
                string executionId = Guid.NewGuid().ToString();
                string testListId  = GetTestListGuid(testListName);

                // UnitTest element.
                SimpleXElement unitTest = CreateElement("UnitTest");

                unitTest.SetAttributeValue("name", name);
                unitTest.SetAttributeValue("storage", storage);
                unitTest.SetAttributeValue("id", testId);

                SimpleXElement owners      = CreateElement("Owners");
                SimpleXElement owner       = CreateElement("Owner");
                string         ownerString = test.Owner ?? string.Empty;

                owner.SetAttributeValue("name", ownerString);
                owners.Add(owner);
                unitTest.Add(owners);

                if (!string.IsNullOrEmpty(test.Description))
                {
                    SimpleXElement description = CreateElement("Description");
                    description.SetValue(test.Description);
                    unitTest.Add(description);
                }

                SimpleXElement execution = CreateElement("Execution");

                execution.SetAttributeValue("id", executionId);
                unitTest.Add(execution);

                // TestMethod element.
                SimpleXElement testMethod = CreateElement("TestMethod");

                testMethod.SetAttributeValue("codeBase", codeBase);
                testMethod.SetAttributeValue("adapterTypeName", adapterTypeName);
                testMethod.SetAttributeValue("className", className);
                testMethod.SetAttributeValue("name", name);
                unitTest.Add(testMethod);

                TestDefinitions.Add(unitTest);

                // TestEntry element.
                SimpleXElement testEntry = CreateElement("TestEntry");

                testEntry.SetAttributeValue("testId", testId);
                testEntry.SetAttributeValue("executionId", executionId);
                testEntry.SetAttributeValue("testListId", testListId);
                TestEntries.Add(testEntry);

                // UnitTestResult element.
                SimpleXElement unitTestResult = CreateElement("UnitTestResult");

                unitTestResult.SetAttributeValue("executionId", executionId);
                unitTestResult.SetAttributeValue("testId", testId);
                unitTestResult.SetAttributeValue("testName", name);
                unitTestResult.SetAttributeValue("computerName", computerName);

                TimeSpan duration = endTime.Subtract(startTime);

                unitTestResult.SetAttributeValue("duration", duration.ToString());

                unitTestResult.SetAttributeValue("startTime", ToDateString(startTime));
                unitTestResult.SetAttributeValue("endTime", ToDateString(endTime));
                unitTestResult.SetAttributeValue("testType", UnitTestTestTypeId);
                unitTestResult.SetAttributeValue("outcome", outcome.ToString());
                unitTestResult.SetAttributeValue("testListId", testListId.ToString());

                // Add any pending items
                foreach (SimpleXElement pending in _pendingElements)
                {
                    unitTestResult.Add(pending);
                }
                _pendingElements.Clear();

                Results.Add(unitTestResult);
            }