예제 #1
0
        /// <summary>
        /// Update Results and Running Test and ProgressBar value
        /// </summary>
        /// <param name="test"></param>
        /// <param name="ResetedTestNum"></param>
        /// <param name="IntegrationDllResult"></param>
        public void UpdateRunningTest(TestResult test, double ResetedTestNum, IntegrationDllResult IntegrationDllResult)
        {
            string resultsValue = string.Format("Results: {0}/{1} passed; {2} failed; {3} not executed.",
                                                IntegrationDllResult.PassedTestNum, IntegrationDllResult.TotalTestNum, IntegrationDllResult.FailedTestNum, IntegrationDllResult.NotExecutedTestNum);

            MainWindow.main.Dispatcher.Invoke(new Action(delegate()
            {
                MainWindow.main.DllResultsValue    = resultsValue;
                MainWindow.main.RunningTestValue   = "Running Test: " + test.TestName;
                MainWindow.main.ResetProgressValue = (ResetedTestNum / IntegrationDllResult.FailedTestNum) * 100;
            }));
        }
예제 #2
0
        /// <summary>
        /// Set all information controls visible and set Dll info
        /// </summary>
        /// <param name="IntegrationDllResult"></param>
        public void UpdateDllInfo(IntegrationDllResult IntegrationDllResult)
        {
            string resultsValue = string.Format("Results: {0}/{1} passed; {2} failed; {3} not executed.",
                                                IntegrationDllResult.PassedTestNum, IntegrationDllResult.TotalTestNum, IntegrationDllResult.FailedTestNum, IntegrationDllResult.NotExecutedTestNum);

            MainWindow.main.Dispatcher.Invoke(new Action(delegate()
            {
                MainWindow.main.ResetProgress.Visibility = Visibility.Visible;
                MainWindow.main.DllName.Visibility       = Visibility.Visible;
                MainWindow.main.DllResults.Visibility    = Visibility.Visible;
                MainWindow.main.RunningTest.Visibility   = Visibility.Visible;

                MainWindow.main.DllNameValue    = "DLL: " + IntegrationDllResult.DllName;
                MainWindow.main.DllResultsValue = resultsValue;
            }));
        }
예제 #3
0
        /// <summary>
        /// Read the new trx file and update the test result
        /// </summary>
        /// <param name="test"></param>
        public void UpdateTestResult(TestResult test)
        {
            IntegrationDllResult integrationDllResult = new IntegrationDllResult();

            DirectoryInfo TestResultsDirInfo = new DirectoryInfo(SingleTestResultsDir);

            FileInfo[] filesInfo = TestResultsDirInfo.GetFiles("*.trx");

            if (filesInfo.Length > 0)
            {
                integrationDllResult = GetIntegrationDllResult(filesInfo[0]);

                test.Outcome   = integrationDllResult.TestResults[0].Outcome;
                test.StdOut    = integrationDllResult.TestResults[0].StdOut;
                test.ErrorInfo = integrationDllResult.TestResults[0].ErrorInfo;
            }
        }
예제 #4
0
        public void WriteIntoFile(IntegrationDllResult integrationDllResult)
        {
            XNamespace ns  = @"http://microsoft.com/schemas/VisualStudio/TeamTest/2010";
            var        doc = XDocument.Load(integrationDllResult.ResultPath);

            foreach (TestResult test in integrationDllResult.FailedTestResults)
            {
                var xElement = (from unitTestResult in doc.Descendants(ns + "UnitTestResult")
                                where (string)unitTestResult.Attribute("testId") == test.TestID
                                select unitTestResult).First();

                //if test outcome changes, update the test result
                if (!xElement.Attribute("outcome").Value.Equals(test.Outcome))
                {
                    xElement.Attribute("outcome").SetValue(test.Outcome);
                    xElement.Element("StdOut").SetValue(test.StdOut);
                    xElement.Element("ErrorInfo").Remove();
                }
            }

            doc.Save(IntegrationTestResultsDir + integrationDllResult.DllName + ".trx");
        }
예제 #5
0
        /// <summary>
        /// Get result informations of one dll
        /// </summary>
        /// <param name="DllResultFile"></param>
        /// <returns></returns>
        public IntegrationDllResult GetIntegrationDllResult(FileInfo DllResultFile)
        {
            IntegrationDllResult IntegrationDllResult = new IntegrationDllResult();

            IntegrationDllResult.ResultPath = DllResultFile.FullName;

            try
            {
                XNamespace ns  = @"http://microsoft.com/schemas/VisualStudio/TeamTest/2010";
                var        doc = XDocument.Load(DllResultFile.FullName);

                //get test's execution codebase and classname
                var testDefinitions = (from unitTest in doc.Descendants(ns + "UnitTest")
                                       select new
                {
                    //executionId = unitTest.Element(ns + "Execution").Attribute("id").Value,
                    testid = unitTest.Attribute("id").Value,
                    codeBase = unitTest.Element(ns + "TestMethod").Attribute("codeBase").Value,
                    className = unitTest.Element(ns + "TestMethod").Attribute("className").Value
                }
                                       ).ToList();

                //get dll name
                string[] sArray = testDefinitions[0].codeBase.Split('\\');
                IntegrationDllResult.DllName = sArray[sArray.Length - 1];

                // get test's testid, testname, classname, outcome, stdout, errorinfo, duration, dllname and assembly path
                var results = (from utr in doc.Descendants(ns + "UnitTestResult")
                               //let executionId = utr.Attribute("executionId").Value
                               let testid = utr.Attribute("testId").Value
                                            let stdout = utr.Descendants(ns + "StdOut").FirstOrDefault()
                                                         let errorinfo = utr.Descendants(ns + "ErrorInfo").FirstOrDefault()
                                                                         //let duration = utr.Attribute("duration")
                                                                         let st = DateTime.Parse(utr.Attribute("startTime").Value).ToUniversalTime()
                                                                                  let et = DateTime.Parse(utr.Attribute("endTime").Value).ToUniversalTime()
                                                                                           select new TestResult()
                {
                    AssemblyPathName = (from td in testDefinitions where td.testid == testid select td.codeBase).Single(),
                    FullClassName = (from td in testDefinitions where td.testid == testid select td.className).Single(),
                    Outcome = utr.Attribute("outcome").Value,
                    TestName = utr.Attribute("testName").Value,
                    StdOut = stdout == null ? "" : stdout.Value,
                    ErrorInfo = errorinfo == null ? "" : errorinfo.Value,
                    //Duration = duration.Value == null ? "" : duration.Value,
                    DllName = IntegrationDllResult.DllName,
                    TestID = testid
                }
                               ).OrderBy(r => r.Outcome).
                              ThenBy(r => r.TestName).
                              ThenBy(r => r.FullClassName);

                //get TestResults list and FailedTestResults list
                IntegrationDllResult.TestResults       = results.ToList();
                IntegrationDllResult.FailedTestResults = IntegrationDllResult.TestResults.Where(n => n.Outcome.Equals("Failed")).ToList();

                // get results number for each outcome
                var counters = doc.Descendants(ns + "ResultSummary").FirstOrDefault().Descendants(ns + "Counters").FirstOrDefault();
                IntegrationDllResult.TotalTestNum  = Int32.Parse(counters.Attribute("total").Value);
                IntegrationDllResult.PassedTestNum = Int32.Parse(counters.Attribute("passed").Value);
                IntegrationDllResult.FailedTestNum = Int32.Parse(counters.Attribute("failed").Value);
            }
            catch (Exception ex)
            {
                throw new Exception("Error while parsing Trx file '" + DllResultFile.FullName + "'\nException: " + ex.ToString());
            }

            return(IntegrationDllResult);
        }
예제 #6
0
 private void summaryDataGrid_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
 {
     IntegrationDllResult integrationDllResult = this.summaryDataGrid.SelectedItem as IntegrationDllResult;
     //this.detailsDataGrid.ItemsSource = integrationDllResult.FailedTestResults;
 }
예제 #7
0
        private void dllDataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            IntegrationDllResult integrationDllResult = this.dllDataGrid.SelectedItem as IntegrationDllResult;

            this.testDataGrid.ItemsSource = integrationDllResult.TestResults;
        }