Beispiel #1
0
        public TestRunSummary Execute()
        {
            var nunitConsolePath = Path.Combine(AssemblyFolderHelper.GetTestAssemblyFolder(), @"NUnit\tools\nunit-console-x86.exe");

            string resultFilePath = Path.Combine(inputProjectDriver.DeploymentFolder, "nunit-result.xml");
            string logFilePath    = Path.Combine(inputProjectDriver.DeploymentFolder, "nunit-result.txt");

            var provessHelper = new ProcessHelper();

            provessHelper.RunProcess(nunitConsolePath, "\"{0}\" \"/xml:{1}\" /labels \"/out={2}\" {3}",
                                     inputProjectDriver.CompiledAssemblyPath, resultFilePath, logFilePath, GetIncludeExclude());

            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);

            return(summary);
        }
        protected override void CallNUnit3(List <string> arguments)
        {
            string nunitConsoleRunnerPath = @"NUnit3-Runner\tools\nunit3-console.exe";
            var    nunitConsolePath       = Path.Combine(AssemblyFolderHelper.GetTestAssemblyFolder(), nunitConsoleRunnerPath);
            var    processHelper          = new ProcessHelper();

            processHelper.RunProcess(nunitConsolePath, string.Join(" ", arguments));
        }
        public TestRunSummary Execute()
        {
            string vsFolder          = Environment.Is64BitProcess ? @"%ProgramFiles(x86)%\Microsoft Visual Studio 14.0\Common7\IDE" : @"%ProgramFiles%\Microsoft Visual Studio 14.0\Common7\IDE";
            var    msTestConsolePath = Path.Combine(AssemblyFolderHelper.GetTestAssemblyFolder(),
                                                    Environment.ExpandEnvironmentVariables(vsFolder + @"\MsTest.exe"));

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

            string testSettingsFilePath = null;

            var processHelper = new ProcessHelper();

            string argumentsFormat = "\"/testcontainer:{0}\" \"/resultsfile:{1}\" /usestderr";

            if (this.TestSettingsFile != null)
            {
                testSettingsFilePath = Path.Combine(
                    inputProjectDriver.CompilationFolder,
                    this.TestSettingsFile.ProjectRelativePath);

                File.WriteAllText(testSettingsFilePath, this.TestSettingsFile.Content, Encoding.UTF8);

                argumentsFormat += " \"/testsettings:{2}\"";
            }

            processHelper.RunProcess(msTestConsolePath, argumentsFormat,
                                     inputProjectDriver.CompiledAssemblyPath, resultsFilePath, testSettingsFilePath);

            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);
        }
Beispiel #4
0
        public override TestRunSummary Execute()
        {
            string resultFilePath = Path.Combine(this.InputProjectDriver.DeploymentFolder, "nunit-result.xml");
            string logFilePath    = Path.Combine(this.InputProjectDriver.DeploymentFolder, "nunit-result.txt");

            var provessHelper    = new ProcessHelper();
            var nunitConsolePath = Path.Combine(AssemblyFolderHelper.GetTestAssemblyFolder(), @"NUnit.Runners\tools\nunit-console-x86.exe");

            provessHelper.RunProcess(nunitConsolePath, "\"{0}\" \"/xml:{1}\" /labels \"/out={2}\" {3}",
                                     this.InputProjectDriver.CompiledAssemblyPath, resultFilePath, logFilePath, this.GetIncludeExclude());

            return(this.ProcessNUnitResult(logFilePath, resultFilePath));
        }
        public TestRunSummary Execute()
        {
            string resultFilePath   = Path.Combine(inputProjectDriver.DeploymentFolder, "xunit-result.xml");
            string logFilePath      = Path.Combine(inputProjectDriver.DeploymentFolder, "xunit-result.txt");
            var    xunitConsolePath = Path.Combine(AssemblyFolderHelper.GetTestAssemblyFolder(), @"xunit.runner.console\tools\xunit.console.exe");

            var provessHelper = new ProcessHelper();

            provessHelper.RunProcess(xunitConsolePath, "\"{0}\" -xml \"{1}\"",
                                     inputProjectDriver.CompiledAssemblyPath, resultFilePath);

            File.WriteAllText(logFilePath, provessHelper.ConsoleOutput);
            return(ProcessXUnitResult(logFilePath, resultFilePath));
        }
        public TestRunSummary ExecuteWithNUnit3() //TODO: add NUnit3 as reference and use in-proc execution
        {
            string resultFilePath = Path.Combine(inputProjectDriver.DeploymentFolder, "nunit-result.xml");
            string logFilePath    = Path.Combine(inputProjectDriver.DeploymentFolder, "nunit-result.txt");

            var    provessHelper          = new ProcessHelper();
            string nunitConsoleRunnerPath = @"NUnit3-Runner\bin\nunit-console.exe";
            var    nunitConsolePath       = Path.Combine(AssemblyFolderHelper.GetTestAssemblyFolder(), nunitConsoleRunnerPath);

            provessHelper.RunProcess(nunitConsolePath, "\"{0}\" \"--result={1};format=nunit2\" --labels=All \"--out={2}\" {3}",
                                     inputProjectDriver.CompiledAssemblyPath, resultFilePath, logFilePath, GetIncludeExclude());

            return(ProcessNUnitResult(logFilePath, resultFilePath));
        }