Exemplo n.º 1
0
        public UnitTestResult Run(IRemoteEventListener listener, ITestFilter filter, string path, string suiteName, List <string> supportAssemblies, string testRunnerType, string testRunnerAssembly, string crashLogFile)
        {
            NUnitTestRunner      runner          = GetRunner(path);
            EventListenerWrapper listenerWrapper = listener != null ? new EventListenerWrapper(listener) : null;

            UnhandledExceptionEventHandler exceptionHandler = (object sender, UnhandledExceptionEventArgs e) => {
                var ex = new RemoteUnhandledException((Exception)e.ExceptionObject);
                File.WriteAllText(crashLogFile, ex.Serialize());
            };

            AppDomain.CurrentDomain.UnhandledException += exceptionHandler;
            try {
                TestResult res = runner.Run(listenerWrapper, filter, path, suiteName, supportAssemblies, testRunnerType, testRunnerAssembly);
                return(listenerWrapper.GetLocalTestResult(res));
            } finally {
                AppDomain.CurrentDomain.UnhandledException -= exceptionHandler;
            }
        }
		public UnitTestResult Run (IRemoteEventListener listener, ITestFilter filter, string path, string suiteName, List<string> supportAssemblies, string testRunnerType, string testRunnerAssembly, string crashLogFile)
		{
			NUnitTestRunner runner = GetRunner (path);
			EventListenerWrapper listenerWrapper = listener != null ? new EventListenerWrapper (listener) : null;
			
			UnhandledExceptionEventHandler exceptionHandler = (object sender, UnhandledExceptionEventArgs e) => {
				
				var ex = new RemoteUnhandledException ((Exception) e.ExceptionObject);
				File.WriteAllText (crashLogFile, ex.Serialize ());
			};

			AppDomain.CurrentDomain.UnhandledException += exceptionHandler;
			try {
				TestResult res = runner.Run (listenerWrapper, filter, path, suiteName, supportAssemblies, testRunnerType, testRunnerAssembly);
				return listenerWrapper.GetLocalTestResult (res);
			} finally {
				AppDomain.CurrentDomain.UnhandledException -= exceptionHandler;
			}
		}