Ejemplo n.º 1
0
        public TestRunSummary Execute()
        {
            string vsFolder = Environment.Is64BitProcess ? @"%ProgramFiles(x86)%\Microsoft Visual Studio 10.0\Common7\IDE" : @"%ProgramFiles%\Microsoft Visual Studio 10.0\Common7\IDE";
            var nunitConsolePath = Path.Combine(AssemblyFolderHelper.GetTestAssemblyFolder(),
                Environment.ExpandEnvironmentVariables(vsFolder + @"\MsTest.exe"));

            string resultsFilePath = Path.Combine(inputProjectDriver.DeploymentFolder, "mstest-result.trx");

            var provessHelper = new ProcessHelper();
            provessHelper.RunProcess(nunitConsolePath, "\"/testcontainer:{0}\" \"/resultsfile:{1}\"", 
                inputProjectDriver.CompiledAssemblyPath, resultsFilePath);

            XDocument logFile = XDocument.Load(resultsFilePath);

            TestRunSummary summary = new TestRunSummary();

            XmlNameTable nameTable = new NameTable();
            XmlNamespaceManager namespaceManager = new XmlNamespaceManager(nameTable);
            namespaceManager.AddNamespace("mstest", "http://microsoft.com/schemas/VisualStudio/TeamTest/2010");

            var summaryElement = logFile.XPathSelectElement("//mstest:ResultSummary/mstest:Counters", namespaceManager);
            if (summaryElement != null)
            {
                summary.Total = int.Parse(summaryElement.Attribute("total").Value);
                summary.Succeeded = int.Parse(summaryElement.Attribute("passed").Value);
                summary.Failed = int.Parse(summaryElement.Attribute("failed").Value);
                summary.Pending = int.Parse(summaryElement.Attribute("inconclusive").Value);
                summary.Ignored = 0; // mstest does not support ignored in the report
            }

            testExecutionResult.LastExecutionSummary = summary;

            return summary;
        }
Ejemplo n.º 2
0
        private TestRunSummary ProcessNUnitResult(string logFilePath, string resultFilePath)
        {
            XDocument resultFileXml = XDocument.Load(resultFilePath);

            TestRunSummary summary = new TestRunSummary();

            summary.Total = resultFileXml.XPathSelectElements("//test-case").Count();
            summary.Succeeded = resultFileXml.XPathSelectElements("//test-case[@executed = 'True' and @success='True']").Count();
            summary.Failed =
                resultFileXml.XPathSelectElements("//test-case[@executed = 'True' and @success='False' and failure]").Count();
            summary.Pending =
                resultFileXml.XPathSelectElements("//test-case[@executed = 'True' and @success='False' and not(failure)]").Count
                    ();
            summary.Ignored = resultFileXml.XPathSelectElements("//test-case[@executed = 'False']").Count();

            testExecutionResult.LastExecutionSummary = summary;
            testExecutionResult.ExecutionLog = File.ReadAllText(logFilePath);

            Console.WriteLine("NUnit LOG:");
            Console.WriteLine(testExecutionResult.ExecutionLog);

            return summary;
        }