44
44
public class NUnitTestRunner: MarshalByRefObject
46
public void Initialize (string nunitPath, string nunitCorePath)
48
// In some cases MS.NET can't properly resolve assemblies even if they
49
// are already loaded. For example, when deserializing objects from remoting.
50
AppDomain.CurrentDomain.AssemblyResolve += delegate (object s, ResolveEventArgs args) {
51
foreach (Assembly am in AppDomain.CurrentDomain.GetAssemblies ()) {
52
if (am.GetName ().FullName == args.Name)
46
public NUnitTestRunner ()
50
public void PreloadAssemblies (string nunitPath, string nunitCorePath, string nunitCoreInterfacesPath)
52
// Note: We need to load all nunit.*.dll assemblies before we do *anything* else in this class
53
// This is to ensure that we always load the assemblies from the monodevelop directory and not
54
// from the directory of the assembly under test. For example we wnat to load
55
// /Applications/MonoDevelop/lib/Addins/nunit.framework.dll and not /user/app/foo/bin/debug/nunit.framework.dll
57
// In some cases MS.NET can't properly resolve assemblies even if they
58
// are already loaded. For example, when deserializing objects from remoting.
59
AppDomain.CurrentDomain.AssemblyResolve += delegate (object s, ResolveEventArgs args) {
60
foreach (Assembly am in AppDomain.CurrentDomain.GetAssemblies ()) {
61
if (am.GetName ().FullName == args.Name)
58
67
// Force the loading of the NUnit.Framework assembly.
59
68
// It's needed since that dll is not located in the test dll directory.
69
Assembly.LoadFrom (nunitCoreInterfacesPath);
60
70
Assembly.LoadFrom (nunitCorePath);
61
71
Assembly.LoadFrom (nunitPath);
74
public void Initialize ()
63
76
// Initialize ExtensionHost if not already done
64
77
if ( !CoreExtensions.Host.Initialized )
65
78
CoreExtensions.Host.InitializeService();
68
public TestResult Run (EventListener listener, ITestFilter filter, string path, string suiteName, List<string> supportAssemblies)
81
public TestResult Run (EventListener listener, ITestFilter filter, string path, string suiteName, List<string> supportAssemblies, string testRunnerType, string testRunnerAssembly)
70
83
InitSupportAssemblies (supportAssemblies);
72
85
if (filter == null)
73
86
filter = TestFilter.Empty;
75
RemoteTestRunner tr = new RemoteTestRunner ();
89
if (!string.IsNullOrEmpty (testRunnerType)) {
91
if (string.IsNullOrEmpty (testRunnerAssembly))
92
runnerType = Type.GetType (testRunnerType, true);
94
var asm = Assembly.LoadFrom (testRunnerAssembly);
95
runnerType = asm.GetType (testRunnerType);
97
tr = (TestRunner)Activator.CreateInstance (runnerType);
99
tr = new RemoteTestRunner ();
76
101
TestPackage package = new TestPackage (path);
77
102
if (!string.IsNullOrEmpty (suiteName))
78
103
package.TestName = suiteName;