public void NothingSpecified()
		{
			MockCSharpProject project = new MockCSharpProject();
			UnitTestApplicationStartHelper helper = new UnitTestApplicationStartHelper();
			helper.Initialize(project, null);
			Assert.AreEqual(@"D:\SharpDevelop\bin\Tools\NUnit\nunit-console-dotnet2-x86.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 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);			
		}
		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);
		}
Exemplo n.º 6
0
        /// <summary>
        /// Runs the test for the project after a successful build.
        /// </summary>
        void OnBuildComplete(BuildResults results, IProject project, string namespaceFilter, IClass fixture, IMember test)
        {
            if (results.ErrorCount == 0 && IsRunningTest)
            {
                UnitTestApplicationStartHelper helper = new UnitTestApplicationStartHelper();

                UnitTestingOptions options = new UnitTestingOptions();
                helper.NoThread   = options.NoThread;
                helper.NoLogo     = options.NoLogo;
                helper.NoDots     = options.NoDots;
                helper.Labels     = options.Labels;
                helper.ShadowCopy = !options.NoShadow;

                if (options.CreateXmlOutputFile)
                {
                    helper.XmlOutputFile = Path.Combine(Path.GetDirectoryName(project.OutputAssemblyFullPath), project.AssemblyName + "-TestResult.xml");
                }

                helper.Initialize(project, namespaceFilter, fixture, test);
                helper.Results = Path.GetTempFileName();

                ResetTestResults(project);

                testResultsMonitor.FileName = helper.Results;
                testResultsMonitor.Start();

                try {
                    RunTests(helper);
                } catch {
                    StopMonitoring();
                    throw;
                }
            }
            else
            {
                if (IsRunningTest)
                {
                    Stop();
                }
                if (TaskService.SomethingWentWrong && ErrorListPad.ShowAfterBuild)
                {
                    ShowErrorList();
                }
            }
        }
Exemplo n.º 7
0
        protected override void RunTests(UnitTestApplicationStartHelper helper)
        {
            bool running = false;

            try {
                TestRunnerCategory.AppendLine(helper.GetCommandLine());
                ProcessStartInfo startInfo = new ProcessStartInfo(helper.UnitTestApplication);
                startInfo.Arguments           = helper.GetArguments();
                startInfo.WorkingDirectory    = UnitTestApplicationStartHelper.UnitTestApplicationDirectory;
                DebuggerService.DebugStopped += DebuggerFinished;
                DebuggerService.CurrentDebugger.Start(startInfo);
                running = true;
            } finally {
                if (!running)
                {
                    DebuggerService.DebugStopped -= DebuggerFinished;
                }
            }
        }
		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 };
		}
		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);
		}
Exemplo n.º 11
0
 protected override void RunTests(UnitTestApplicationStartHelper helper)
 {
     TestRunnerCategory.AppendLine(helper.GetCommandLine());
     runner.Start(helper.UnitTestApplication, helper.GetArguments());
 }
Exemplo n.º 12
0
 protected abstract void RunTests(UnitTestApplicationStartHelper helper);
		protected override void RunTests(UnitTestApplicationStartHelper helper)
		{
			SetPartCoverRunnerProperties(helper);
			RunPartCover();
		}
Exemplo n.º 14
0
		/// <summary>
		/// Runs the test for the project after a successful build.
		/// </summary>
		void OnBuildComplete(BuildResults results, IProject project, string namespaceFilter, IClass fixture, IMember test)
		{
			if (results.ErrorCount == 0 && IsRunningTest) {
				UnitTestApplicationStartHelper helper = new UnitTestApplicationStartHelper();
				
				UnitTestingOptions options = new UnitTestingOptions();
				helper.NoThread = options.NoThread;
				helper.NoLogo = options.NoLogo;
				helper.NoDots = options.NoDots;
				helper.Labels = options.Labels;
				helper.ShadowCopy = !options.NoShadow;
				
				if (options.CreateXmlOutputFile) {
					helper.XmlOutputFile = Path.Combine(Path.GetDirectoryName(project.OutputAssemblyFullPath), project.AssemblyName + "-TestResult.xml");
				}
				
				helper.Initialize(project, namespaceFilter, fixture, test);
				helper.Results = Path.GetTempFileName();
				
				ResetTestResults(project);

				testResultsMonitor.FileName = helper.Results;
				testResultsMonitor.Start();
				
				try {
					RunTests(helper);
				} catch {
					StopMonitoring();
					throw;
				}
			} else {
				if (IsRunningTest) {
					Stop();
				}
				if (TaskService.SomethingWentWrong && ErrorListPad.ShowAfterBuild) {
					ShowErrorList();
				}
			}
		}
Exemplo n.º 15
0
		protected override void RunTests(UnitTestApplicationStartHelper helper)
		{
			bool running = false;
			
			try {
				TestRunnerCategory.AppendLine(helper.GetCommandLine());
				ProcessStartInfo startInfo = new ProcessStartInfo(helper.UnitTestApplication);
				startInfo.Arguments = helper.GetArguments();
				startInfo.WorkingDirectory = UnitTestApplicationStartHelper.UnitTestApplicationDirectory;
				DebuggerService.DebugStopped += DebuggerFinished;
				DebuggerService.CurrentDebugger.Start(startInfo);
				running = true;
			} finally {
				if (!running) {
					DebuggerService.DebugStopped -= DebuggerFinished;
				}
			}
		}
Exemplo n.º 16
0
		protected override void RunTests(UnitTestApplicationStartHelper helper)
		{
			TestRunnerCategory.AppendLine(helper.GetCommandLine());
			runner.Start(helper.UnitTestApplication, helper.GetArguments());
		}
		void AfterFinish(UnitTestApplicationStartHelper helper, string path)
		{
			helper.Project.AddSessionToProject(path);
			WorkbenchSingleton.SafeThreadAsyncCall(TestsFinished);
			LoggingService.Info("shutting profiler down...");
		}
Exemplo n.º 18
0
		protected abstract void RunTests(UnitTestApplicationStartHelper helper);