/// <summary> /// Create and initialize the standard set of services /// used in the Engine. This interface is not normally /// called by user code. Programs linking only to /// only to the nunit.engine.api assembly are given a /// pre-initialized instance of TestEngine. Programs /// that link directly to nunit.engine usually do so /// in order to perform custom initialization. /// </summary> public void InitializeServices() { SettingsService settingsService = new SettingsService("NUnit30Settings.xml", true); if(InternalTraceLevel == InternalTraceLevel.Default) InternalTraceLevel = (InternalTraceLevel)settingsService.GetSetting("Options.InternalTraceLevel", InternalTraceLevel.Off); if(InternalTraceLevel != InternalTraceLevel.Off) { var logName = string.Format("InternalTrace.{0}.log", Process.GetCurrentProcess().Id); InternalTrace.Initialize(Path.Combine(WorkDirectory, logName), InternalTraceLevel); } this.Services.Add(settingsService); this.Services.Add(new RecentFilesService()); this.Services.Add(new DomainManager()); this.Services.Add(new ProjectService()); this.Services.Add(new RuntimeFrameworkSelector()); this.Services.Add(new DefaultTestRunnerFactory()); this.Services.Add(new DriverFactory()); this.Services.Add(new TestAgency()); this.Services.ServiceManager.InitializeServices(); }
public static int Main(string[] args) { AgentId = new Guid(args[0]); AgencyUrl = args[1]; bool pause = false, verbose = false; for (int i = 2; i < args.Length; i++) switch (args[i]) { case "--pause": pause = true; break; case "--verbose": verbose = true; break; } #if DEBUG if (pause) System.Windows.Forms.MessageBox.Show("Attach debugger if desired, then press OK", "NUnit-Agent"); #endif // Create SettingsService early so we know the trace level right at the start SettingsService settingsService = new SettingsService("NUnit30Settings.xml", false); //InternalTrace.Initialize("nunit-agent_%p.log", (InternalTraceLevel)settingsService.GetSetting("Options.InternalTraceLevel", InternalTraceLevel.Default)); //log.Info("Agent process {0} starting", Process.GetCurrentProcess().Id); //log.Info("Running under version {0}, {1}", // Environment.Version, // RuntimeFramework.CurrentFramework.DisplayName); if (verbose) { Console.WriteLine("Agent process {0} starting", Process.GetCurrentProcess().Id); Console.WriteLine("Running under version {0}, {1}", Environment.Version, RuntimeFramework.CurrentFramework.DisplayName); } // Create TestEngine - this program is // conceptually part of the engine and // can access it's internals as needed. TestEngine engine = new TestEngine(); // Custom Service Initialization //log.Info("Adding Services"); engine.Services.Add(settingsService); engine.Services.Add(new ProjectService()); engine.Services.Add(new DomainManager()); engine.Services.Add(new InProcessTestRunnerFactory()); engine.Services.Add(new DriverFactory()); //engine.Services.Add( new TestLoader() ); // Initialize Services //log.Info("Initializing Services"); engine.Services.ServiceManager.InitializeServices(); Channel = ServerUtilities.GetTcpChannel(); //log.Info("Connecting to TestAgency at {0}", AgencyUrl); try { Agency = Activator.GetObject(typeof(ITestAgency), AgencyUrl) as ITestAgency; } catch (Exception ex) { Console.WriteLine("Unable to connect\r\n{0}", ex); //log.Error("Unable to connect", ex); } if (Channel != null) { //log.Info("Starting RemoteTestAgent"); RemoteTestAgent agent = new RemoteTestAgent(AgentId, Agency, engine.Services); try { if (agent.Start()) { //log.Debug("Waiting for stopSignal"); agent.WaitForStop(); //log.Debug("Stop signal received"); } else Console.WriteLine("Failed to start RemoteTestAgent"); //log.Error("Failed to start RemoteTestAgent"); } catch (Exception ex) { //log.Error("Exception in RemoteTestAgent", ex); Console.WriteLine("Exception in RemoteTestAgent", ex); } //log.Info("Unregistering Channel"); try { ChannelServices.UnregisterChannel(Channel); } catch (Exception ex) { //log.Error("ChannelServices.UnregisterChannel threw an exception", ex); Console.WriteLine("ChannelServices.UnregisterChannel threw an exception\r\n{0}", ex); } } if (verbose) Console.WriteLine("Agent process {0} exiting", Process.GetCurrentProcess().Id); //log.Info("Agent process {0} exiting", Process.GetCurrentProcess().Id); //InternalTrace.Close(); return 0; }
/// <summary> /// Initialize the engine. This includes initializing mono addins, /// setting the trace level and creating the standard set of services /// used in the Engine. /// /// This interface is not normally called by user code. Programs linking /// only to the nunit.engine.api assembly are given a /// pre-initialized instance of TestEngine. Programs /// that link directly to nunit.engine usually do so /// in order to perform custom initialization. /// </summary> public void Initialize() { #if NUNIT_ENGINE if (!AddinManager.IsInitialized) { // Pass in the current nunit.engine assembly because mono.addins uses the executing assembly by // default and that might be in a an entirely different directory than the runner that is using it. AddinManager.Initialize(Assembly.GetExecutingAssembly(), NUnitConfiguration.ApplicationDirectory); AddinManager.Registry.Update(null); } #endif SettingsService settingsService = new SettingsService(true); if(InternalTraceLevel == InternalTraceLevel.Default) InternalTraceLevel = settingsService.GetSetting("Options.InternalTraceLevel", InternalTraceLevel.Off); if(InternalTraceLevel != InternalTraceLevel.Off) { var logName = string.Format("InternalTrace.{0}.log", Process.GetCurrentProcess().Id); InternalTrace.Initialize(Path.Combine(WorkDirectory, logName), InternalTraceLevel); } Services.Add(settingsService); Services.Add(new DomainManager()); Services.Add(new DriverService()); #if NUNIT_ENGINE Services.Add(new RecentFilesService()); Services.Add(new ProjectService()); Services.Add(new RuntimeFrameworkService()); Services.Add(new DefaultTestRunnerFactory()); Services.Add(new TestAgency()); Services.Add(new ResultService()); #else Services.Add(new CoreTestRunnerFactory()); #endif Services.ServiceManager.StartServices(); }
/// <summary> /// Initialize the engine. This includes initializing mono addins, /// setting the trace level and creating the standard set of services /// used in the Engine. /// /// This interface is not normally called by user code. Programs linking /// only to the nunit.engine.api assembly are given a /// pre-initialized instance of TestEngine. Programs /// that link directly to nunit.engine usually do so /// in order to perform custom initialization. /// </summary> public void Initialize() { SettingsService settingsService = new SettingsService(true); if(InternalTraceLevel == InternalTraceLevel.Default) InternalTraceLevel = settingsService.GetSetting("Options.InternalTraceLevel", InternalTraceLevel.Off); if(InternalTraceLevel != InternalTraceLevel.Off) { var logName = string.Format("InternalTrace.{0}.log", Process.GetCurrentProcess().Id); InternalTrace.Initialize(Path.Combine(WorkDirectory, logName), InternalTraceLevel); } Services.Add(settingsService); Services.Add(new DomainManager()); #if NUNIT_ENGINE Services.Add(new ExtensionService()); #endif Services.Add(new DriverService()); #if NUNIT_ENGINE Services.Add(new RecentFilesService()); Services.Add(new ProjectService()); Services.Add(new RuntimeFrameworkService()); Services.Add(new DefaultTestRunnerFactory()); Services.Add(new TestAgency()); Services.Add(new ResultService()); #else Services.Add(new CoreTestRunnerFactory()); #endif Services.ServiceManager.StartServices(); }