Exemple #1
0
        internal static void HandelCodeClassSelection(AbstractTestFramework testFramework, CodeFunction function, DTE2 applicationObject, UnitTestCodeType codeType)
        {
            Project parentProject = ProjectExaminar.GetCodeClassParentProject((CodeClass)function.Parent);

            Project unitTestProject = ProjectExaminar.GetUnitTestProject(parentProject.Name, applicationObject, testFramework.TestProjectPostFix);

            //We might or might not use this factory, we don't know at this point
            AbstractTestClassFactory testClassFactory = new NUnitTestClassFactory();

            foreach (ProjectItem projectItem in unitTestProject.ProjectItems)
            {
                System.Collections.Generic.List <CodeClass> lstCodeClasses =
                    ProjectItemExaminor.GetCodeClasses(projectItem.FileCodeModel);

                foreach (CodeClass codeClass in lstCodeClasses)
                {
                    CodeClass parentClass = (CodeClass)function.Parent;

                    string className     = codeClass.Name;
                    string testClassName = ((CodeClass)function.Parent).Name + testFramework.TestClassFixturePostFix;

                    //find the parent for function passed in
                    //if (codeClass.Name.Equals(((CodeClass)function.Parent).Name + CommonStrings.DEFAULT_STRING_SEPERATOR + UTGHelper.CommonStrings.DEFAULT_UNIT_TEST_CLASS_POSTFIX))
                    if (className.Equals(testClassName) == true)
                    {
                        //if found
                        AbstractTestClass nunitClass = null;

                        if (codeType == UnitTestCodeType.CSharp)
                        {
                            nunitClass = testClassFactory.CreateCSharpTestClass(codeClass.Namespace.FullName, codeClass.Name, codeClass.IsAbstract);
                        }
                        else if (codeType == UnitTestCodeType.VB)
                        {
                            nunitClass = testClassFactory.CreateVBTestClass(codeClass.Namespace.FullName, codeClass.Name, codeClass.IsAbstract);
                        }

                        nunitClass.GenerateTest(codeClass, function);

                        //we sure expect just one class, the first class we find matching
                        return;
                    }
                }
            }

            //if we have reached this point then it means that we have not been able to locate a parent class in our
            //unit test project, then we simply create a class unit test

            OnCodeClassSelection(testFramework, (CodeClass)function.Parent, (CodeElement)function, applicationObject, unitTestProject, codeType);
        }
        protected override string FormatFrameworkArgument(TestFixturOption runOption)
        {
            if (runOption.Project == null)
            {
                throw new ArgumentNullException("testFixturOption.Project can not be null");
            }

            string outPutXml = "OpenCoverOutput.xml";

            #region example in plain test
            //OpenCover.Console.exe -register:user -target:nunit-console-x86.exe -targetargs:"/noshadow Test.dll" -filter:+[*]* -output:coverage.xml
            #endregion

            //We are better off with a StringBuilder here but since this is not an operation often performed we can get away with it
            string tvArguments = string.Empty;

            tvArguments += " -register:user ";

            tvArguments += "-target:\"" + System.IO.Path.Combine(this.testFramework.ConsoleDirectory, this.testFramework.ConsoleName);

            Project project = runOption.Project;

            string projectPath = ProjectExaminar.GetProjectPath(project);

            string tvOutputReportFullName = projectPath + "\\" + outPutXml;

            if (System.IO.File.Exists(tvOutputReportFullName))
            {
                System.IO.File.Delete(tvOutputReportFullName);
            }

            if (!UTGHelper.IO.CreateFile(tvOutputReportFullName))
            {
                return(string.Empty);
            }

            tvArguments += "\" -output:\"";

            tvArguments += ToShortPathName(tvOutputReportFullName);

            tvArguments += "\" -targetargs:\"/noshadow ";

            tvArguments += GetProjectOutputPath(runOption);

            //Just to get this working we are not filtering however recode this so that we filter based on the runOption
            tvArguments += "\" -filter:+[*]*";

            return(tvArguments);
        }
Exemple #3
0
        internal static void OnCodeClassSelection(AbstractTestFramework testFramework, CodeFunction ce, DTE2 applicationObject, UnitTestCodeType codeType)
        {
            Project parentProject = ProjectExaminar.GetCodeClassParentProject((CodeClass)ce.Parent);

            Project unitTestProject = ProjectExaminar.GetUnitTestProject(parentProject.Name, applicationObject, testFramework.TestProjectPostFix);

            if (unitTestProject == null)
            {
                OnCodeClassSelection(testFramework, (CodeClass)ce.Parent, (CodeElement)ce, applicationObject, codeType);
                return;
            }

            //In cases where we can not simply generate automatically (definition already exists) we will
            //ask the user for input, wait on input, then async back to the function actual useful handler
            //HandelCodeClassSelection
            if (!CanGenerateHandleCodeFunction(testFramework.TestClassFixturePostFix, (CodeClass)ce.Parent, ce, unitTestProject))
            {
                //UTGHelper.ErrorHandler.HandleMessage(CommonUserMessages.MSG_TEST_ALREADY_EXISTS);

                UTGHelper.UserAlertActionRequired tvUserAlertActionRequired = new UserAlertActionRequired(
                    "Function definition already exits! What would you like to do?",
                    typeof(CodeFunction),
                    (CodeElement)ce,
                    ref applicationObject,
                    codeType,
                    testFramework);

                if (!tvUserAlertActionRequired.IsDisposed)
                {
                    tvUserAlertActionRequired.FormClosed += new System.Windows.Forms.FormClosedEventHandler(tvUserAlertActionRequired_FormClosed);

                    tvUserAlertActionRequired.Show();
                }
                else
                {
                    HandelCodeClassSelection(testFramework, ce, applicationObject, codeType);
                }

                return;
            }

            //otherwise simply call HandelCodeClassSelection
            HandelCodeClassSelection(testFramework, ce, applicationObject, codeType);
        }
Exemple #4
0
        internal static void HandelCodeClassSelection(AbstractTestFramework testFramework, CodeProperty property, DTE2 applicationObject, UnitTestCodeType codeType)
        {
            Project parentProject = ProjectExaminar.GetCodeClassParentProject((CodeClass)property.Parent);

            Project unitTestProject = ProjectExaminar.GetUnitTestProject(parentProject.Name, applicationObject, testFramework.TestProjectPostFix);

            //We might or might not use this factory, we don't know at this point
            AbstractTestClassFactory testClassFactory = new NUnitTestClassFactory();

            foreach (ProjectItem projectItem in unitTestProject.ProjectItems)
            {
                System.Collections.Generic.List <CodeClass> lstCodeClasses =
                    ProjectItemExaminor.GetCodeClasses(projectItem.FileCodeModel);

                foreach (CodeClass codeClass in lstCodeClasses)
                {
                    if (codeClass.Name.Equals(((CodeClass)property.Parent).Name + testFramework.TestClassFixturePostFix))
                    {
                        //if found
                        AbstractTestClass nunitClass = null;

                        if (codeType == UnitTestCodeType.CSharp)
                        {
                            nunitClass = testClassFactory.CreateCSharpTestClass(codeClass.Namespace.FullName, codeClass.Name, codeClass.IsAbstract);
                        }
                        else if (codeType == UnitTestCodeType.VB)
                        {
                            nunitClass = testClassFactory.CreateVBTestClass(codeClass.Namespace.FullName, codeClass.Name, codeClass.IsAbstract);
                        }

                        nunitClass.GenerateTest(codeClass, property);

                        //we sure expect just one class, the first class we find matching
                        return;
                    }
                }
            }

            //if we have reached this point then it means that we have not been able to locate a parent class in our
            //unit test project, then we simply create a class unit test

            OnCodeClassSelection(testFramework, (CodeClass)property.Parent, (CodeElement)property, applicationObject, unitTestProject, codeType);
        }
        protected string GetProjectOutputPath(TestFixturOption testFixtureOptions)
        {
            //Need to get output path and output filename here
            Properties properties = testFixtureOptions.Project.ConfigurationManager.ActiveConfiguration.Properties;

            foreach (Property property in properties)
            {
                if (property.Name.Equals("OutputPath"))
                {
                    string pName = property.Name;
                    string value = property.Value as string;

                    if (value != null)
                    {
                        return(ToShortPathName(ProjectExaminar.GetProjectPath(testFixtureOptions.Project)) + "\\" + value + testFixtureOptions.Project.Name + ".dll");
                    }
                }
            }

            return(string.Empty);
        }
Exemple #6
0
        //OK
        internal static void OnCodeClassSelection(AbstractTestFramework testFramework, CodeClass codeClass, DTE2 applicationObject, UnitTestCodeType codeType)
        {
            //We can only test public methods
            if (codeClass.Access != vsCMAccess.vsCMAccessPublic)
            {
                return;
            }

            Project parentProject = ProjectExaminar.GetCodeClassParentProject(codeClass);

            Project unitTestProject = ProjectExaminar.GetUnitTestProject(parentProject.Name, applicationObject, testFramework.TestProjectPostFix);

            if (unitTestProject != null && !CanGenerateHandleCodeClass(testFramework.TestClassFixturePostFix, codeClass, unitTestProject))
            {
                UTGHelper.ErrorHandler.ShowMessage(CommonUserMessages.MSG_TEST_ALREADY_EXISTS);
                OnGenerationFaliure(applicationObject);
                return;
            }

            string path = ProjectManager.GetUnitTestProjectPath(parentProject.Name, applicationObject, testFramework.TestProjectPostFix);

            path = UTGHelper.IO.GetFilePath(path);

            System.IO.DirectoryInfo newDirectoryInfo;

            string fullPath = System.IO.Path.Combine(path, parentProject.Name + testFramework.TestProjectPostFix);

            try{
                //Another way of doing this would be to try and find this project in current open solution saving us the exception
                newDirectoryInfo =
                    System.IO.Directory.CreateDirectory(fullPath);
            }
            catch (Exception ex) {
                Logger.LogException(ex);
            }
            finally{
                //Either case we have one by now so lets get its directory information
                newDirectoryInfo = new System.IO.DirectoryInfo(fullPath);
            }

            //If for whatever reason we are still failing then simply quit this
            if (newDirectoryInfo == null)
            {
                OnGenerationFaliure(applicationObject);

                throw new Exception(string.Format("Unable to create new Directory {0}", System.IO.Path.Combine(path, parentProject.Name + testFramework.TestProjectPostFix)));
            }

            if (unitTestProject == null)
            {
                try{
                    unitTestProject = ProjectManager.CreateAndAddUnitTestProject((Solution2)applicationObject.Solution, parentProject.Name + testFramework.TestProjectPostFix, newDirectoryInfo.FullName, codeType /*, license*/);
                }
                catch (Exception ex) {
                    Logger.LogException(ex);

                    OnGenerationFaliure(applicationObject);

                    throw;
                }
            }

            //Rethink this bit
            //Since above operation fails in either case then try getting the new Unit Test Project if created and added ok..
            if (unitTestProject == null)
            {
                unitTestProject = ProjectExaminar.GetUnitTestProject(parentProject.Name, applicationObject, testFramework.TestProjectPostFix);
            }

            if (unitTestProject == null)
            {
                OnGenerationFaliure(applicationObject);
                throw new Exception("Can not create new UnitTest Project");
            }

            AbstractTestClassFactory testClassFactory = new NUnitTestClassFactory();

            AbstractTestClass nunitClass = null;

            if (codeType == UnitTestCodeType.CSharp)
            {
                nunitClass = testClassFactory.CreateCSharpTestClass(codeClass.Namespace.FullName, codeClass.Name, codeClass.IsAbstract);
            }
            else if (codeType == UnitTestCodeType.VB)
            {
                nunitClass = testClassFactory.CreateVBTestClass(codeClass.Namespace.FullName, codeClass.Name, codeClass.IsAbstract);
            }

            if (!nunitClass.write(newDirectoryInfo.FullName, testFramework.TestClassFixturePostFix))
            {
                OnGenerationFaliure(applicationObject);
                return;
            }

            //add new class to project
            ProjectItem projectItem = ProjectManager.AddClassToProject(applicationObject, unitTestProject, null, nunitClass.FullName);

            List <CodeClass> lstCodeClasses = ProjectItemExaminor.GetCodeClasses(projectItem.FileCodeModel);

            if (lstCodeClasses == null || lstCodeClasses.Count == 0)
            {
                OnGenerationFaliure(applicationObject);
                return;
            }

            CodeClass unitTestCodeClass = lstCodeClasses[0];

            //passed this point the actual object will take care of it self.
            nunitClass.GenerateTest(unitTestCodeClass, codeClass);

            //To consider: this should be handled by an object that inherits from project type
            copyReferences(testFramework, parentProject, unitTestProject);

            applicationObject.ItemOperations.OpenFile(nunitClass.FullName, EnvDTE.Constants.vsViewKindAny);
        }
        public override bool Examine(TestFixturOption testFixturOption, DTE2 applicationObject)
        {
            if (testFixturOption.Project == null)
            {
                throw new ArgumentNullException("testFixturOption.Project can not be null");
            }

            if (applicationObject == null)
            {
                throw new ArgumentNullException("applicationObject can not be null");
            }

            try
            {
                string outPutXml = "OpenCoverOutput.xml";

                if (this.binariesDirectory == null || this.binariesDirectory == string.Empty)
                {
                    BrowseForCoverLibraries tvLocateNUnitBinaries = new BrowseForCoverLibraries(UTGHelper.CommonErrors.ERR_UNABLE_TO_LOCATE_COVER_INSTALL_FOLDER, this);

                    tvLocateNUnitBinaries.Show();

                    return(false);
                }

                Project project = testFixturOption.Project;

                string projectPath = ProjectExaminar.GetProjectPath(project);

                if (CoverageExaminationStarted != null)
                {
                    CoverageExaminationStarted();
                }

                string tvArgument = FormatFrameworkArgument(testFixturOption);

                System.Diagnostics.ProcessStartInfo psi =
                    new System.Diagnostics.ProcessStartInfo(System.IO.Path.Combine(this.ConsoleDirectory, this.ConsoleName), tvArgument);

                psi.UseShellExecute = false;

                psi.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;

                psi.RedirectStandardOutput = true;

                psi.CreateNoWindow = true; //this is the one that works

                System.Diagnostics.Process process = System.Diagnostics.Process.Start(psi);

                System.IO.StreamReader myOutput = process.StandardOutput;

                string output = string.Empty;

                if (!process.WaitForExit(exitWaitPeriod))
                {
                    return(false);
                }

                output += myOutput.ReadToEnd();

                bool success = ShowReport(projectPath, outPutXml);

                if (success)
                {
                    if (CoverageExaminationEnded != null)
                    {
                        CoverageExaminationEnded(project, "Changed text to something else here...");
                    }
                }

                //consider moving to http://reportgenerator.codeplex.com/ instead....

                return(true);
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
            }

            return(false);
        }
Exemple #8
0
        public override bool run(TestFixturOption testFixturOption, DTE2 applicationObject)
        {
            try
            {
                string output = string.Empty;
                string tvTestFixtureOptions = string.Empty;
                string tvOutputFileFullname = string.Empty;

                if (testFixturOption.CClass != null)
                {
                    tvTestFixtureOptions = " /fixture:";

                    tvTestFixtureOptions += testFixturOption.CClass.FullName;

                    tvOutputFileFullname = UTGManagerAndExaminor.ProjectExaminar.GetProjectOutputFullAssemblyName(testFixturOption.CClass.ProjectItem.ContainingProject);

                    tvTestFixtureOptions += " \"" + tvOutputFileFullname + "\"";

                    if (testFixturOption.ConfigurationFile != string.Empty)
                    {
                        tvTestFixtureOptions += " /config:\"" + tvOutputFileFullname + ".config\"";
                    }
                }
                else if (testFixturOption.CFunction != null)
                {
                    tvTestFixtureOptions = " /run:";

                    CodeClass parentClass = testFixturOption.CFunction.Parent as CodeClass;

                    tvTestFixtureOptions += testFixturOption.CFunction.FullName;

                    tvOutputFileFullname = UTGManagerAndExaminor.ProjectExaminar.GetProjectOutputFullAssemblyName(parentClass.ProjectItem.ContainingProject);

                    tvTestFixtureOptions += " \"" + tvOutputFileFullname + "\"";

                    if (tvTestFixtureOptions.Length > 0)
                    {
                        if (testFixturOption.ConfigurationFile != string.Empty)
                        {
                            tvTestFixtureOptions += " /config:\"" + tvOutputFileFullname + ".config\"";
                        }
                    }
                }
                else
                {
                    if (tvOutputFileFullname.Equals(string.Empty))
                    {
                        tvOutputFileFullname = UTGManagerAndExaminor.ProjectExaminar.GetProjectOutputFullAssemblyName(testFixturOption.Project);
                        tvTestFixtureOptions = "\"" + tvOutputFileFullname + "\"";
                    }

                    if (testFixturOption.ConfigurationFile != string.Empty)
                    {
                        tvTestFixtureOptions += " /config:\"" + tvOutputFileFullname + ".config\"";
                    }
                }

                tvTestFixtureOptions += " /xmlConsole";

                ProjectExaminar.GetProjectOutputType(testFixturOption.Project);

                ProjectItem projectItem = ProjectExaminar.GetProjectConfigurationFile(testFixturOption.Project);

                Project project = testFixturOption.Project;

                if (this.binariesDirectory == null || this.binariesDirectory == string.Empty)
                {
                    BrowseForUnitLibraries tvLocateNUnitBinaries = new BrowseForUnitLibraries(
                        UTGHelper.CommonErrors.ERR_UNABLE_TO_LOCATE_NUNIT_INSTALL_FOLDER, BrowseForUnitLibraries.BrowseForNunitDialogType.libraries, this);

                    tvLocateNUnitBinaries.Show();

                    return(false);
                }

                if (this.consoleDirectory == null || this.consoleDirectory == string.Empty)
                {
                    BrowseForUnitLibraries tvLocateNUnitBinaries = new BrowseForUnitLibraries(
                        UTGHelper.CommonErrors.ERR_UNABLE_TO_LOCATE_NUNIT_CONSOLE, BrowseForUnitLibraries.BrowseForNunitDialogType.console, this);

                    tvLocateNUnitBinaries.Show();

                    return(false);
                }

                string processFullPath = System.IO.Path.Combine(this.consoleDirectory, this.ConsoleName);

                if (TestStarted != null)
                {
                    TestStarted();
                }

#if _PROCESS_START_WIN32_
                ProcessTypes.StartupInfo startInfo   = new ProcessTypes.StartupInfo();
                ProcessTypes.ProcessInfo processInfo = new ProcessTypes.ProcessInfo();

                IntPtr ThreadHandle = IntPtr.Zero;

                string commandLine = (arguments != null ? libraryPath + arguments : libraryPath);

                //string commandLine = @"C:\Users\Sam\documents\visual studio 2010\Projects\MyClassLibrary\MyClassLibrary.nunit\bin\Debug\MyClassLibrary.nunit.dll";

                bool success = CreateProcess(processFullPath, commandLine, IntPtr.Zero, IntPtr.Zero, false,
                                             ProcessTypes.ProcessCreationFlags.CREATE_SUSPENDED,
                                             IntPtr.Zero, null, ref startInfo, out processInfo);

                if (!success)
                {
                    UTGHelper.Logger.LogMessage("Failed to start unit test process");
                    return(false);
                }

                ThreadHandle = processInfo.hThread;
                uint PID = processInfo.dwProcessId;

                ResumeThread(ThreadHandle);

                return(true);
#else
                System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo(processFullPath, tvTestFixtureOptions);

                //we choose to redirect output, but we could also just use the TestResult.xml file
                psi.RedirectStandardOutput = true;

                psi.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;

                psi.UseShellExecute = false;

                psi.CreateNoWindow = true; //this is the one that works

                System.Diagnostics.Process process = System.Diagnostics.Process.Start(psi);

                if (testFixturOption.IsDebugging)
                {
                    AttachToProcessThread(applicationObject);
                }

                System.IO.StreamReader myOutput = process.StandardOutput;

                process.WaitForExit(60000);

                if (!process.HasExited)
                {
                    UTGHelper.ErrorHandler.ShowMessage(UTGHelper.CommonErrors.ERR_UNABLE_TO_RUN_UNITTEST + " " + "Failed to exit process");

                    return(false);
                }

                output += myOutput.ReadToEnd();
#endif
                //This should be fixed by simple passing the argument that suppresses the copyright text /nologo
                output = PatchFunctionMessageTestOutput(output);

                if (output.Equals(string.Empty))
                {
                    UTGHelper.ErrorHandler.ShowMessage(UTGHelper.CommonErrors.ERR_UNABLE_TO_RUN_UNITTEST);

                    return(false);
                }

                System.Xml.XmlDocument xmlTestResultDoc =
                    NUnitXmlResultProccessor.ToXmlDoc(output);

                System.Xml.XmlNodeList xmlTestResultsNodeList =
                    NUnitXmlResultProccessor.GetTestCases(xmlTestResultDoc);

                List <System.Xml.XmlNode> successfulTestSuites =
                    NUnitXmlResultProccessor.GetSuccessfulTestSuites(xmlTestResultsNodeList);

                List <System.Xml.XmlNode> failedTestSuites =
                    NUnitXmlResultProccessor.GetFailedTestSuites(xmlTestResultsNodeList);

                List <System.Xml.XmlNode> failedExecutionSuites =
                    NUnitXmlResultProccessor.GetFailedExecutionSuites(xmlTestResultsNodeList);

                List <UnitTestError> lstUnitTestPassed =
                    NUnitXmlResultProccessor.GetSuccessfulTestSuitesAsUnitTestErrors(successfulTestSuites);

                List <UnitTestError> lstUnitTestErrors =
                    NUnitXmlResultProccessor.GetFailedTestSuitesAsUnitTestErrors(failedTestSuites);

                List <UnitTestError> lstUnitTestsFialedToExecute =
                    NUnitXmlResultProccessor.GetFailedExecutionsAsUnitTestErrors(failedExecutionSuites);

                if (TestEnded != null)
                {
                    TestEnded(testFixturOption.Project, lstUnitTestPassed, lstUnitTestErrors, lstUnitTestsFialedToExecute);
                }

                return(true);
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
            }

            return(false);
        }
        protected override string FormatFrameworkArgument(TestFixturOption runOption)
        {
            #region example in plain test
            //PartCover.exe
            //--target="C:\Program Files\NUnit 2.4.6\bin\nunit-console.exe"
            //--target-args="C:\Temp\MyClassLibrary\MyClassLibrary.nunit\MyClassLibrary.nunit.csproj"
            //--include=[MyClassLibrary]*
            #endregion

            //fix was found http://www.pinvoke.net/default.aspx/kernel32.GetShortPathName
            string tvArguments = string.Empty;

            tvArguments += "--target=\"" + System.IO.Path.Combine(this.CommandsDirectory, this.ConsoleName);

            string tvOutputReportFullName = ProjectExaminar.GetProjectPath(runOption.Project) + "\\PartCoverOutput.xml";

            if (System.IO.File.Exists(tvOutputReportFullName))
            {
                System.IO.File.Delete(tvOutputReportFullName);
            }

            if (!UTGHelper.IO.CreateFile(tvOutputReportFullName))
            {
                return(string.Empty);
            }

            tvArguments += "\" --output=\"";

            tvArguments += ToShortPathName(tvOutputReportFullName);

            tvArguments += "\" --target-args=\"";

            //Next line can be iffy when doing this runOption.Project.Name + ".csproj"
            tvArguments += ToShortPathName(ProjectExaminar.GetProjectPath(runOption.Project)) + "\\" + runOption.Project.Name + ".csproj";

            if (runOption.CClass == null)
            {
                tvArguments += "\" --include=[";
                tvArguments += ProjectExaminar.GetProjectNamespaceName(ProjectExaminar.GetUnitTestProjectsOriginalProject(
                                                                           runOption.Project.Name, (DTE2)runOption.Project.DTE, testFramework.TestProjectPostFix));
                tvArguments += "]";
                tvArguments += "*";
            }
            else
            {
                tvArguments += "\"";

                string tvClassName      = ProjectItemExaminor.GetUnitTestClassOriginalClassName(runOption.CClass.Name, testFramework.TestClassFixturePostFix);
                string tvClassNamespace = ProjectItemExaminor.GetUnitTestClassOriginalClassNamespace(runOption.CClass.Namespace.FullName);

                Project project = ProjectExaminar.GetUnitTestProjectsOriginalProject(runOption.Project.Name, (DTE2)runOption.Project.DTE, testFramework.TestProjectPostFix);

                if (project == null)
                {
                    throw new Exception(string.Format("Unable to locate Unit Test Project for the Project {0}.", runOption.Project.Name));
                }

                tvArguments += " --include=[";
                tvArguments += ProjectExaminar.GetProjectNamespaceName(project);
                tvArguments += "]";
                tvArguments += tvClassNamespace;
                tvArguments += ".";
                tvArguments += tvClassName;
                tvArguments += "* ";
            }

            return(tvArguments);
        }
        public override bool Examine(TestFixturOption testFixturOption, DTE2 applicationObject)
        {
            if (testFixturOption.Project == null)
            {
                throw new ArgumentNullException("testFixturOption.Project can not be null");
            }

            if (applicationObject == null)
            {
                throw new ArgumentNullException("applicationObject can not be null");
            }

            try
            {
                if (this.binariesDirectory == null || this.binariesDirectory == string.Empty)
                {
                    BrowseForCoverLibraries tvLocateNUnitBinaries = new BrowseForCoverLibraries(UTGHelper.CommonErrors.ERR_UNABLE_TO_LOCATE_COVER_INSTALL_FOLDER, this);

                    tvLocateNUnitBinaries.Show();

                    return(false);
                }

                Project project = testFixturOption.Project;

                if (CoverageExaminationStarted != null)
                {
                    CoverageExaminationStarted();
                }

                string tvArgument = FormatFrameworkArgument(testFixturOption);

                System.Diagnostics.ProcessStartInfo psi =
                    new System.Diagnostics.ProcessStartInfo(System.IO.Path.Combine(this.BinariesDirectory, this.CommandName), tvArgument);

                psi.UseShellExecute = false;

                psi.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;

                psi.RedirectStandardOutput = true;

                psi.CreateNoWindow = true; //this is the one that works

                System.Diagnostics.Process process = System.Diagnostics.Process.Start(psi);

                System.IO.StreamReader myOutput = process.StandardOutput;

                string output = string.Empty;

                if (!process.WaitForExit(exitWaitPeriod))
                {
                    return(false);
                }

                output += myOutput.ReadToEnd();

                UTGCoverage.CoverageReport report = new UTGCoverage.CoverageReport();

                System.IO.StreamReader reader = new System.IO.StreamReader(ProjectExaminar.GetProjectPath(testFixturOption.Project) + "\\PartCoverOutput.xml");

                UTGCoverage.ReportProvider.ReadReport(report, reader);

                reader.Close();

                System.Windows.Forms.TreeView trview = UTGCoverage.ReportProvider.ShowReport(report, UTGHelper.PartCoverUserControle.treeView1);

                UTGHelper.PartCoverUserControle.treeView1.Refresh();

                if (CoverageExaminationEnded != null)
                {
                    CoverageExaminationEnded(testFixturOption.Project, string.Format("{0} at {1}.", "PartCoverOutput.xml", ProjectExaminar.GetProjectPath(testFixturOption.Project)));
                }

                return(true);
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
            }

            return(false);
        }