コード例 #1
0
ファイル: RunInfo.cs プロジェクト: zcsizmadia/vstest
        /// <summary>
        /// Saves the class under the XmlElement..
        /// </summary>
        /// <param name="element">
        /// The parent xml.
        /// </param>
        /// <param name="parameters">
        /// The parameters.
        /// </param>
        public void Save(XmlElement element, XmlTestStoreParameters parameters)
        {
            XmlPersistence helper = new XmlPersistence();

            helper.SaveSingleFields(element, this, parameters);
            helper.SaveSimpleField(element, "Exception", this.exception, null);
        }
コード例 #2
0
ファイル: TestListCategory.cs プロジェクト: zcsizmadia/vstest
        /// <summary>
        /// Saves the class under the XmlElement..
        /// </summary>
        /// <param name="element">
        /// The parent xml.
        /// </param>
        /// <param name="parameters">
        /// The parameter
        /// </param>
        public void Save(System.Xml.XmlElement element, XmlTestStoreParameters parameters)
        {
            XmlPersistence h = new XmlPersistence();

            h.SaveSingleFields(element, this, parameters);
            h.SaveGuid(element, "@id", this.Id.Id);
            h.SaveGuid(element, "@parentListId", this.ParentCategoryId.Id);
        }
コード例 #3
0
        /// <summary>
        /// Saves the class under the XmlElement..
        /// </summary>
        /// <param name="element">
        /// The parent xml.
        /// </param>
        /// <param name="parameters">
        /// The parameter
        /// </param>
        public void Save(XmlElement element, XmlTestStoreParameters parameters)
        {
            XmlPersistence helper = new XmlPersistence();

            helper.SaveSingleFields(element, this, parameters);
            helper.SaveIEnumerable(this.runLevelErrorsAndWarnings, element, "RunInfos", ".", "RunInfo", parameters);
            helper.SaveIEnumerable(this.resultFiles, element, "ResultFiles", "@path", "ResultFile", parameters);
            helper.SaveIEnumerable(this.collectorDataEntries, element, "CollectorDataEntries", ".", "Collector", parameters);
        }
コード例 #4
0
ファイル: TestEntry.cs プロジェクト: navin22/nvstest
        /// <summary>
        /// Saves the class under the XmlElement..
        /// </summary>
        /// <param name="element">
        /// The parent xml.
        /// </param>
        /// <param name="parameters">
        /// The parameters.
        /// </param>
        public void Save(System.Xml.XmlElement element, XmlTestStoreParameters parameters)
        {
            XmlPersistence helper = new XmlPersistence();

            helper.SaveSingleFields(element, this, parameters);

            helper.SaveObject(this.testId, element, null);
            helper.SaveGuid(element, "@executionId", this.execId.Id);
            helper.SaveGuid(element, "@testListId", this.categoryId.Id);
        }
コード例 #5
0
ファイル: TestEntry.cs プロジェクト: zcsizmadia/vstest
        /// <summary>
        /// Saves the class under the XmlElement..
        /// </summary>
        /// <param name="element">
        /// The parent xml.
        /// </param>
        /// <param name="parameters">
        /// The parameters.
        /// </param>
        public void Save(System.Xml.XmlElement element, XmlTestStoreParameters parameters)
        {
            XmlPersistence helper = new XmlPersistence();

            helper.SaveSingleFields(element, this, parameters);

            helper.SaveObject(this.testId, element, null);
            helper.SaveGuid(element, "@executionId", this.executionId);
            if (parentExecutionId != null)
            {
                helper.SaveGuid(element, "@parentExecutionId", this.parentExecutionId);
            }
            helper.SaveGuid(element, "@testListId", this.categoryId.Id);
            if (this.TestEntries.Count > 0)
            {
                helper.SaveIEnumerable(TestEntries, element, "TestEntries", ".", "TestEntry", parameters);
            }
        }
コード例 #6
0
        /// <summary>
        /// Saves the class under the XmlElement..
        /// </summary>
        /// <param name="element">
        /// The parent xml.
        /// </param>
        /// <param name="parameters">
        /// The parameters.
        /// </param>
        public void Save(XmlElement element, XmlTestStoreParameters parameters)
        {
            XmlPersistence helper = new XmlPersistence();

            // Save all fields marked as StoreXmlSimpleField.
            helper.SaveSingleFields(element, this, parameters);

            helper.SaveGuid(element, "@id", this.id.Id);

            // When saving and loading a TRX file, we want to use the run deployment root directory based on where the TRX file
            // is being saved to or loaded from
            object filePersistenceRootObjectType;

            if (parameters.TryGetValue(XmlFilePersistence.RootObjectType, out filePersistenceRootObjectType) &&
                (Type)filePersistenceRootObjectType == typeof(TestRun))
            {
                Debug.Assert(
                    parameters.ContainsKey(XmlFilePersistence.DirectoryPath),
                    "TestRun is the type of the root object being saved to a file, but the DirectoryPath was not specified in the XML test store parameters");

                Debug.Assert(
                    !string.IsNullOrEmpty(this.runDeploymentRoot),
                    "TestRun is the type of the root object being saved to a file, but the run deployment root directory is null or empty");

                // We are saving a TestRun object as the root element in a file (TRX file), so just save the test run directory
                // name (last directory in the run deployment root), which is the relative path to the run deployment root
                // directory from the directory where the TRX file exists
                helper.SaveSimpleField(
                    element,
                    "Deployment/@runDeploymentRoot",
                    FileHelper.MakePathRelative(this.runDeploymentRoot, Path.GetDirectoryName(this.runDeploymentRoot)),
                    string.Empty);
            }
            else
            {
                // We are not saving a TestRun object as the root element in a file (i.e., we're not saving a TRX file), so just
                // save the run deployment root directory as is
                helper.SaveSimpleField(element, "Deployment/@runDeploymentRoot", this.runDeploymentRoot, string.Empty);
            }
        }
コード例 #7
0
        /// <summary>
        /// Called when a test run is completed.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// Test run complete events arguments.
        /// </param>
        internal void TestRunCompleteHandler(object sender, TestRunCompleteEventArgs e)
        {
            // Create test run
            // If abort occurs there is no call to TestResultHandler which results in testRun not created.
            // This happens when some test aborts in the first batch of execution.
            if (this.testRun == null)
            {
                CreateTestRun();
            }

            XmlPersistence         helper      = new XmlPersistence();
            XmlTestStoreParameters parameters  = XmlTestStoreParameters.GetParameters();
            XmlElement             rootElement = helper.CreateRootElement("TestRun");

            // Save runId/username/creation time etc.
            this.testRun.Finished = DateTime.UtcNow;
            helper.SaveSingleFields(rootElement, this.testRun, parameters);

            // Save test settings
            helper.SaveObject(this.testRun.RunConfiguration, rootElement, "TestSettings", parameters);

            // Save test results
            helper.SaveIEnumerable(this.results.Values, rootElement, "Results", ".", null, parameters);

            // Save test definitions
            helper.SaveIEnumerable(this.testElements.Values, rootElement, "TestDefinitions", ".", null, parameters);

            // Save test entries
            helper.SaveIEnumerable(this.entries.Values, rootElement, "TestEntries", ".", "TestEntry", parameters);

            // Save default categories
            List <TestListCategory> categories = new List <TestListCategory>();

            categories.Add(TestListCategory.UncategorizedResults);
            categories.Add(TestListCategory.AllResults);
            helper.SaveList(categories, rootElement, "TestLists", ".", "TestList", parameters);

            // Save summary
            if (this.testRunOutcome == TrxLoggerObjectModel.TestOutcome.Passed)
            {
                this.testRunOutcome = TrxLoggerObjectModel.TestOutcome.Completed;
            }

            testRunOutcome = changeTestOutcomeIfNecessary(testRunOutcome);

            List <string>             errorMessages    = new List <string>();
            List <CollectorDataEntry> collectorEntries = this.converter.ToCollectionEntries(e.AttachmentSets, this.testRun, this.testResultsDirPath);
            IList <string>            resultFiles      = this.converter.ToResultFiles(e.AttachmentSets, this.testRun, this.testResultsDirPath, errorMessages);

            if (errorMessages.Count > 0)
            {
                // Got some errors while attaching files, report them and set the outcome of testrun to be Error...
                this.testRunOutcome = TrxLoggerObjectModel.TestOutcome.Error;
                foreach (string msg in errorMessages)
                {
                    RunInfo runMessage = new RunInfo(msg, null, Environment.MachineName, TrxLoggerObjectModel.TestOutcome.Error);
                    this.runLevelErrorsAndWarnings.Add(runMessage);
                }
            }

            TestRunSummary runSummary = new TestRunSummary(
                this.totalTests,
                this.passTests + this.failTests,
                this.passTests,
                this.failTests,
                this.testRunOutcome,
                this.runLevelErrorsAndWarnings,
                this.runLevelStdOut.ToString(),
                resultFiles,
                collectorEntries);

            helper.SaveObject(runSummary, rootElement, "ResultSummary", parameters);


            this.ReserveTrxFilePath();
            this.PopulateTrxFile(this.trxFilePath, rootElement);
        }