Ejemplo n.º 1
0
 private async Task RunNunitTests(string openCoverCommandLine, string arguments, ProjectInfo projectInfo, Guid fileNameGuid, QueuedTest testQueueItem)
 {
     await RunTests(openCoverCommandLine, arguments, projectInfo, fileNameGuid, testQueueItem);
 }
Ejemplo n.º 2
0
        private async Task RunTests(string openCoverCommandLine, string arguments, ProjectInfo projectInfo, Guid fileNameGuid, QueuedTest testQueueItem)
        {
            // BuildProject(_solutionDirectory + testQueueItem.ProjectName);
            Log.DebugFormat("Verify project executing on Thread: {0}", System.Threading.Thread.CurrentThread.ManagedThreadId);

            var coverFilename = fileNameGuid.ToString() + "-cover.xml";

            var resultFilename = fileNameGuid.ToString() + "-result.xml";

            var startInfo = new System.Diagnostics.ProcessStartInfo {
                FileName  = openCoverCommandLine,
                Arguments = arguments + coverFilename,
                RedirectStandardOutput = true,
                WindowStyle            = ProcessWindowStyle.Hidden,
                UseShellExecute        = false,
                CreateNoWindow         = true
            };

            Log.DebugFormat("ProcessStartInfo.Arguments: {0}", startInfo.Arguments.ToString());
            Log.DebugFormat("ProcessStartInfo.FileName: {0}", startInfo.FileName.ToString());
            var args = new string[] { @"-target:C:\USERS\LEE\APPDATA\LOCAL\MICROSOFT\VISUALSTUDIO\11.0EXP\EXTENSIONS\LEEM\TESTIFY\1.0\NUnit.Runners.2.6.2\nunit-console.exe ",
                                      @"-targetargs:C:\WIP\UnitTestExperiment\Domain.Test\bin\Debug\Domain.Test.dll /result:C:\Users\Lee\AppData\Local\Testify\UnitTestExperiment\5ce700cd-e242-46fd-b817-ff276495e958-result.xml /noshadow",
                                      @"-coverbytest:*.Test.dll",
                                      @"-hideskipped: Domain",
                                      @"-filter:+[MyProduct.Domain]* +[Domain.Test]*",
                                      @"-register:user" };
            //var launcher = new OpenCoverLauncher(args);


            string stdout;

            try
            {
                // Start the process with the info we specified.
                // Call WaitForExit and then the using statement will close.
                using (System.Diagnostics.Process exeProcess = System.Diagnostics.Process.Start(startInfo))
                {
                    //long AffinityMask = (long)exeProcess.ProcessorAffinity;
                    //AffinityMask = 0x0002; // use only the second processor, despite availability
                    //exeProcess.ProcessorAffinity = (IntPtr)AffinityMask;

                    if (testQueueItem.IndividualTests == null)
                    {
                        // lower the priority if running all tests for a project.
                        exeProcess.PriorityClass = ProcessPriorityClass.BelowNormal;
                    }

                    stdout = exeProcess.StandardOutput.ReadToEnd();

                    await Task.Run(() => exeProcess.WaitForExit());

                    Log.DebugFormat("Results of Unit Test run: {0}", stdout);
                }
            }
            catch (Exception ex)
            {
                // Log error.
                Log.ErrorFormat("Error ocurred while RunTest for Project: {0}: Error:{1}", projectInfo.ProjectAssemblyName, ex.Message);
            }

            string fileToRead = GetOutputFolder() + coverFilename;

            await ProcessCoverageSessionResults(projectInfo, testQueueItem, resultFilename, fileToRead);
        }
Ejemplo n.º 3
0
        private StringBuilder GetTestParameters(string projectName, List <string> individualTests, ProjectInfo projectInfo, Guid fileNameGuid)
        {
            var testParameters = new StringBuilder();

            testParameters.Append(GetTarget());
            if (individualTests.Any())
            {
                testParameters.Append("/run:");

                testParameters.Append(GetCommaSeparatedListOfTests(individualTests));
                testParameters.Append(" ");
            }
            const int timeout = 3000;

            testParameters.Append(projectInfo.TestProject.Path);
            testParameters.Append(".dll");
            testParameters.Append(" /result:");
            testParameters.Append(_outputFolder);
            testParameters.Append(fileNameGuid);
            testParameters.Append("-result.xml ");

            testParameters.Append(" /timeout=" + timeout);
            testParameters.Append("\"");
            testParameters.Append(" -coverbytest:*.Test.dll -hideskipped: ");
            testParameters.Append(Path.GetFileNameWithoutExtension(projectName));
            testParameters.Append(" -skipautoprops: ");

            testParameters.Append(" -filter:\"+[" + projectInfo.ProjectAssemblyName + "]* +[" + projectInfo.TestProject.AssemblyName + "]* \"");
            testParameters.Append(" -targetdir:" + Path.GetDirectoryName(projectInfo.TestProject.Path));
            testParameters.Append(" -register:user -output:");
            testParameters.Append(_outputFolder);

            return(testParameters);
        }