public void NothingSpecified()
        {
            MockCSharpProject project             = new MockCSharpProject();
            UnitTestApplicationStartHelper helper = new UnitTestApplicationStartHelper();

            helper.Initialize(project, null);
            Assert.AreEqual(@"D:\SharpDevelop\bin\Tools\NUnit\nunit-console.exe", helper.UnitTestApplication);
        }
 public void SetUp()
 {
     project              = new MockCSharpProject();
     project.FileName     = @"C:\Projects\MyTests\MyTests.csproj";
     project.AssemblyName = "MyTests";
     project.OutputType   = OutputType.Library;
     helper = new UnitTestApplicationStartHelper();
 }
 public void SetUp()
 {
     project              = new MockCSharpProject();
     project.FileName     = @"C:\Projects\MyTests\MyTests.csproj";
     project.AssemblyName = "MyTests";
     project.OutputType   = OutputType.Library;
     project.SetProperty("OutputPath", ".");             // don't create bin/Debug
     project.SetProperty("TargetFrameworkVersion", "v4.0");
     helper = new UnitTestApplicationStartHelper();
 }
        public void NotMSBuildBasedProject()
        {
            MissingProject project = new MissingProject(@"C:\Projects\Test.proj", "Test");
            UnitTestApplicationStartHelper helper = new UnitTestApplicationStartHelper();

            helper.Initialize(project, null);

            Assert.AreEqual(project.GetType().BaseType, typeof(AbstractProject), "MissingProject should be derived from AbstractProject.");
            Assert.AreEqual(@"D:\SharpDevelop\bin\Tools\NUnit\nunit-console.exe", helper.UnitTestApplication);
        }
        public void NUnitConsole32BitUsedWhenTargetCpuIs32Bit()
        {
            MockCSharpProject project = new MockCSharpProject();

            project.ActiveConfiguration = "Debug";
            project.ActivePlatform      = "AnyCPU";
            project.SetProperty("PlatformTarget", "x86");

            UnitTestApplicationStartHelper helper = new UnitTestApplicationStartHelper();

            helper.Initialize(project, null);
            Assert.AreEqual(@"D:\SharpDevelop\bin\Tools\NUnit\nunit-console-x86.exe", helper.UnitTestApplication);
        }
Esempio n. 6
0
        public void TargetCpuAnyCPUDotnet2()
        {
            MockCSharpProject project = new MockCSharpProject();

            project.ActiveConfiguration = "Debug";
            project.ActivePlatform      = "AnyCPU";
            project.SetProperty("PlatformTarget", "AnyCPU");
            project.SetProperty("TargetFrameworkVersion", "v3.5");

            UnitTestApplicationStartHelper helper = new UnitTestApplicationStartHelper();

            helper.Initialize(project, null);
            Assert.AreEqual(@"D:\SharpDevelop\bin\Tools\NUnit\nunit-console-dotnet2.exe", helper.UnitTestApplication);
        }
        protected override void RunTests(UnitTestApplicationStartHelper helper)
        {
            TestRunnerCategory.AppendLine(helper.GetCommandLine());

            ProcessStartInfo startInfo = new ProcessStartInfo(helper.UnitTestApplication);

            string path = helper.Project.GetSessionFileName();

            startInfo.Arguments        = helper.GetArguments();
            startInfo.WorkingDirectory = UnitTestApplicationStartHelper.UnitTestApplicationDirectory;
            LoggingService.Info("starting profiler...");

            runner = new ProfilerRunner(startInfo, true, new ProfilingDataSQLiteWriter(path, true, GetUnitTestNames(helper).ToArray()));

            runner.RunFinished += delegate {
                WorkbenchSingleton.SafeThreadCall(() => FileService.OpenFile(path));
                AfterFinish(helper, path);
            };

            runner.Run();
        }
        IEnumerable <string> GetUnitTestNames(UnitTestApplicationStartHelper helper)
        {
            IProjectContent content = ParserService.GetProjectContent(helper.Project);

            if (helper.Fixture == null)
            {
                var testClasses = content.Classes
                                  .Where(c => c.Attributes.Any(a => a.AttributeType.FullyQualifiedName == "NUnit.Framework.TestFixtureAttribute"));
                return(testClasses
                       .SelectMany(c2 => c2.Methods)
                       .Where(m => m.Attributes.Any(a2 => a2.AttributeType.FullyQualifiedName == "NUnit.Framework.TestAttribute"))
                       .Select(m2 => m2.FullyQualifiedName));
            }

            if (helper.Test == null)
            {
                return(content.Classes
                       .Where(c => c.FullyQualifiedName == helper.Fixture).First().Methods
                       .Where(m => m.Attributes.Any(a2 => a2.AttributeType.FullyQualifiedName == "NUnit.Framework.TestAttribute"))
                       .Select(m2 => m2.FullyQualifiedName));
            }

            return(new[] { helper.Fixture + "." + helper.Test });
        }
Esempio n. 9
0
        void SetPartCoverRunnerProperties(UnitTestApplicationStartHelper helper)
        {
            string            partCoverOutputDirectory = GetPartCoverOutputDirectory(helper.Project);
            PartCoverSettings settings = GetPartCoverSettings(helper.Project);

            // By default get the code coverage for everything if
            // no include or exclude regular expressions have been
            // set for this project. Note that the CodeCoverageResults
            // will ignore any type that has no source code available
            // for it even though the type may be in the Part Cover
            // results file.
            if (settings.Include.Count == 0)
            {
                settings.Include.Add("[*]*");
            }

            runner.PartCoverFileName      = GetPartCoverFileName();
            runner.Target                 = helper.UnitTestApplication;
            runner.TargetArguments        = helper.GetArguments();
            runner.TargetWorkingDirectory = Path.GetDirectoryName(helper.Assemblies[0]);
            runner.Output                 = Path.Combine(partCoverOutputDirectory, "Coverage.Xml");
            AddStringsToCollection(settings.Include, runner.Include);
            AddStringsToCollection(settings.Exclude, runner.Exclude);
        }
 void AfterFinish(UnitTestApplicationStartHelper helper, string path)
 {
     helper.Project.AddSessionToProject(path);
     WorkbenchSingleton.SafeThreadAsyncCall(TestsFinished);
     LoggingService.Info("shutting profiler down...");
 }
Esempio n. 11
0
 protected override void RunTests(UnitTestApplicationStartHelper helper)
 {
     SetPartCoverRunnerProperties(helper);
     RunPartCover();
 }