Example #1
0
        public TestRunResults RunTests(Project project, string assemblyName)
        {
            var timer = Stopwatch.StartNew();
            var unitTestExe = _configuration.MSTestRunner(project.Value.Framework);
            if (!File.Exists(unitTestExe))
                return new TestRunResults(project.Key, assemblyName, new TestResult[] { });

            var proc = new Process();
            proc.StartInfo = new ProcessStartInfo(unitTestExe,
                                                        "/testcontainer:\"" + assemblyName + "\" /detail:errorstacktrace /detail:errormessage");
            proc.StartInfo.RedirectStandardOutput = true;
            proc.StartInfo.WorkingDirectory = Path.GetDirectoryName(assemblyName);
            proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
            proc.StartInfo.UseShellExecute = false;
            proc.StartInfo.CreateNoWindow = true;

            proc.Start();
            string line;
            var parser = new MSTestResponseParser(project.Key, assemblyName);
            while ((line = proc.StandardOutput.ReadLine()) != null)
                parser.ParseLine(line);
            proc.WaitForExit();
            timer.Stop();
            parser.Result.SetTimeSpent(timer.Elapsed);
            return parser.Result;
        }
Example #2
0
        public TestRunResults[] RunTests(TestRunInfo[] runInfos, Action <AutoTest.TestRunners.Shared.Targeting.Platform, Action <ProcessStartInfo> > processWrapper, Func <bool> abortWhen)
        {
            var results = new List <TestRunResults>();

            foreach (var runInfo in runInfos)
            {
                var timer       = Stopwatch.StartNew();
                var unitTestExe = _configuration.MSTestRunner(getFramework(runInfo));
                if (!File.Exists(unitTestExe))
                {
                    var project = "";
                    if (runInfo.Project != null)
                    {
                        project = runInfo.Project.Key;
                    }
                    results.Add(new TestRunResults(project, runInfo.Assembly, false, TestRunner.MSTest, new TestResult[] { }));
                    continue;
                }

                if (runInfo.OnlyRunSpcifiedTestsFor(TestRunner.MSTest) && runInfo.GetTestsFor(TestRunner.MSTest).Length.Equals(0))
                {
                    continue;
                }
                var calc          = new MaxCmdLengthCalculator();
                var tests         = getTestsList(runInfo);
                var testRunConfig = getTestrunConfigArguments();
                var arguments     = "/testcontainer:\"" + runInfo.Assembly + "\" " + tests + " /detail:errorstacktrace /detail:errormessage" + testRunConfig;
                var runAllTests   = (arguments.Length + unitTestExe.Length) > calc.GetLength();
                if (runAllTests)
                {
                    arguments = "/testcontainer:\"" + runInfo.Assembly + "\"" + " /detail:errorstacktrace /detail:errormessage" + testRunConfig;
                }
                DebugLog.Debug.WriteInfo("Running tests: {0} {1}", unitTestExe, arguments);
                var proc = new Process();
                proc.StartInfo = new ProcessStartInfo(unitTestExe, arguments);
                proc.StartInfo.RedirectStandardOutput = true;
                proc.StartInfo.WorkingDirectory       = Path.GetDirectoryName(runInfo.Assembly);
                proc.StartInfo.WindowStyle            = ProcessWindowStyle.Hidden;
                proc.StartInfo.UseShellExecute        = false;
                proc.StartInfo.CreateNoWindow         = true;

                proc.Start();
                string line;
                var    parser = new MSTestResponseParser(runInfo.Project.Key, runInfo.Assembly, !runAllTests);
                while ((line = proc.StandardOutput.ReadLine()) != null)
                {
                    parser.ParseLine(line);
                }
                proc.WaitForExit();
                timer.Stop();
                parser.Result.SetTimeSpent(timer.Elapsed);
                results.Add(parser.Result);
            }
            return(results.ToArray());
        }
        public TestRunResults[] RunTests(TestRunInfo[] runInfos, Action<AutoTest.TestRunners.Shared.Targeting.Platform, Version, Action<ProcessStartInfo, bool>> processWrapper, Func<bool> abortWhen)
        {
			var results = new List<TestRunResults>();
			foreach (var runInfo in runInfos)
			{			
	            var timer = Stopwatch.StartNew();
	            var unitTestExe = _configuration.MSTestRunner(getFramework(runInfo));
	            if (!File.Exists(unitTestExe))
				{
					var project = "";
					if (runInfo.Project != null)
						project = runInfo.Project.Key;
	                results.Add(new TestRunResults(project, runInfo.Assembly, false, TestRunner.MSTest, new TestResult[] { }));
					continue;
				}
				
                if (runInfo.OnlyRunSpcifiedTestsFor(TestRunner.MSTest) && runInfo.GetTestsFor(TestRunner.MSTest).Length.Equals(0))
                    continue;
				var calc = new MaxCmdLengthCalculator();
				var tests = getTestsList(runInfo);
                var testRunConfig = getTestrunConfigArguments();
				var arguments = "/testcontainer:\"" + runInfo.Assembly + "\" " + tests + " /detail:errorstacktrace /detail:errormessage" + testRunConfig;
                var runAllTests = (arguments.Length + unitTestExe.Length) > calc.GetLength();
				if (runAllTests)
                    arguments = "/testcontainer:\"" + runInfo.Assembly + "\"" + " /detail:errorstacktrace /detail:errormessage" + testRunConfig;
				DebugLog.Debug.WriteInfo("Running tests: {0} {1}", unitTestExe, arguments); 
	            var proc = new Process();
	            proc.StartInfo = new ProcessStartInfo(unitTestExe, arguments);
	            proc.StartInfo.RedirectStandardOutput = true;
	            proc.StartInfo.WorkingDirectory = Path.GetDirectoryName(runInfo.Assembly);
	            proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
	            proc.StartInfo.UseShellExecute = false;
	            proc.StartInfo.CreateNoWindow = true;
	
	            proc.Start();
	            string line;
	            var parser = new MSTestResponseParser(runInfo.Project.Key, runInfo.Assembly, !runAllTests);
	            while ((line = proc.StandardOutput.ReadLine()) != null)
	                parser.ParseLine(line);
	            proc.WaitForExit();
	            timer.Stop();
	            parser.Result.SetTimeSpent(timer.Elapsed);
	            results.Add(parser.Result);
			}
			return results.ToArray();
        }
Example #4
0
        public TestRunResults[] RunTests(TestRunInfo[] runInfos)
        {
			var results = new List<TestRunResults>();
			foreach (var runInfo in runInfos)
			{			
	            var timer = Stopwatch.StartNew();
	            var unitTestExe = _configuration.MSTestRunner(getFramework(runInfo));
	            if (!File.Exists(unitTestExe))
				{
					var project = "";
					if (runInfo.Project != null)
						project = runInfo.Project.Key;
	                results.Add(new TestRunResults(project, runInfo.Assembly, new TestResult[] { }));
					continue;
				}
				
                if (runInfo.OnlyRunSpcifiedTests && runInfo.TestsToRun.Length.Equals(0))
                    continue;
				var tests = getTestsList(runInfo);
				var arguments = "/testcontainer:\"" + runInfo.Assembly + "\" " + tests + " /detail:errorstacktrace /detail:errormessage";
				DebugLog.Debug.WriteMessage(string.Format("Running tests: {0} {1}", unitTestExe, arguments)); 
	            var proc = new Process();
	            proc.StartInfo = new ProcessStartInfo(unitTestExe, arguments);
	            proc.StartInfo.RedirectStandardOutput = true;
	            proc.StartInfo.WorkingDirectory = Path.GetDirectoryName(runInfo.Assembly);
	            proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
	            proc.StartInfo.UseShellExecute = false;
	            proc.StartInfo.CreateNoWindow = true;
	
	            proc.Start();
	            string line;
	            var parser = new MSTestResponseParser(runInfo.Project.Key, runInfo.Assembly);
	            while ((line = proc.StandardOutput.ReadLine()) != null)
	                parser.ParseLine(line);
	            proc.WaitForExit();
	            timer.Stop();
	            parser.Result.SetTimeSpent(timer.Elapsed);
	            results.Add(parser.Result);
			}
			return results.ToArray();
        }
 public void SetUp()
 {
     _parser = new MSTestResponseParser("", "");
 }
         public void Should_set_result_as_partial_when_partial_is_passed()
         {
             var isPartial = true;
             var parser = new MSTestResponseParser("project", "assembly", isPartial);
             var result = parser.Result;

             result.IsPartialTestRun.ShouldBeTrue();
         }