[Adapdev-commits] Adapdev/src/Adapdev.UnitTest.Core LocalTestEngine.cs,1.1.1.1,1.2 TestSuiteBuilder.
Status: Beta
Brought to you by:
intesar66
From: Sean M. <int...@us...> - 2005-04-23 04:54:22
|
Update of /cvsroot/adapdev/Adapdev/src/Adapdev.UnitTest.Core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25984/src/Adapdev.UnitTest.Core Modified Files: LocalTestEngine.cs TestSuiteBuilder.cs Log Message: Index: TestSuiteBuilder.cs =================================================================== RCS file: /cvsroot/adapdev/Adapdev/src/Adapdev.UnitTest.Core/TestSuiteBuilder.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** TestSuiteBuilder.cs 14 Apr 2005 03:32:05 -0000 1.2 --- TestSuiteBuilder.cs 23 Apr 2005 04:54:13 -0000 1.3 *************** *** 65,69 **** ts.AddTestAssembly(this.BuildAssembly(assemblyName)); } ! catch(FileNotFoundException){} } --- 65,72 ---- ts.AddTestAssembly(this.BuildAssembly(assemblyName)); } ! catch(FileNotFoundException) ! { ! log.Error("Assembly couldn't be found: " + assemblyName); ! } } *************** *** 75,78 **** --- 78,82 ---- // set delegate to probe for an assembly when it's not found in the base path AppDomain.CurrentDomain.AssemblyResolve +=new ResolveEventHandler(CurrentDomain_AssemblyResolve); + AppDomain.CurrentDomain.AssemblyLoad += new AssemblyLoadEventHandler(CurrentDomain_AssemblyLoad); // switch the current directory to the assemblies location *************** *** 96,117 **** // Build the TestAssembly information TestAssembly ta = new TestAssembly(); ! ta.AssemblyName = fi.Name; ! ta.AssemblyFullName = assembly.FullName; ! ta.Name = assembly.GetName().Name; ! ta.Path = assembly.Location; ! ta.Location = fi.DirectoryName; ! ta.OriginalPath = assemblyName; ! ta.Id = id++; ! ! // Build the TestFixtures ! foreach (Type t in assembly.GetExportedTypes()) { ! ta.AddTestFixture(this.BuildTestFixture(t, ta, assembly)); ! } ! // restore the original environment ! Environment.CurrentDirectory = orig; ! // if(this._debugMode) log.Debug(ta.ToString()); return ta; } --- 100,127 ---- // Build the TestAssembly information TestAssembly ta = new TestAssembly(); ! try { ! ta.AssemblyName = fi.Name; ! ta.AssemblyFullName = assembly.FullName; ! ta.Name = assembly.GetName().Name; ! ta.Path = assembly.Location; ! ta.Location = fi.DirectoryName; ! ta.OriginalPath = assemblyName; ! ta.Id = id++; ! // Build the TestFixtures ! foreach (Type t in assembly.GetExportedTypes()) ! { ! ta.AddTestFixture(this.BuildTestFixture(t, ta, assembly)); ! } + // restore the original environment + Environment.CurrentDirectory = orig; + if(log.IsDebugEnabled) log.Debug(ta.ToString()); + } + catch (Exception e) + { + log.Error("Unable to create TestAssembly", e); + } return ta; } *************** *** 124,172 **** ) { ! // Build the TestFixture ! tf = new Adapdev.UnitTest.Core.TestFixture(); ! tf.Parent = ta; ! tf.Class = t.Name; ! tf.Name = t.Name; ! tf.Namespace = t.Namespace; ! tf.FullName = t.FullName; ! tf.Id = id++; ! this.ProcessCommonAttributes(t, tf); ! foreach (MethodInfo mi in t.GetMethods()) ! { ! if (TypeHelper.HasCustomAttribute(mi, typeof (Adapdev.UnitTest.TestAttribute)) ! || TypeHelper.HasCustomAttribute(mi, typeof (NUnit.Framework.TestAttribute))) ! { ! tf.AddTest(this.BuildTest(mi, tf)); ! } ! else if (TypeHelper.HasCustomAttribute(mi, typeof (Adapdev.UnitTest.TestFixtureSetUpAttribute)) ! || TypeHelper.HasCustomAttribute(mi, typeof (NUnit.Framework.TestFixtureSetUpAttribute))) ! { ! tf.AddFixtureSetUp(this.BuildBaseTestHelper(mi, tf)); ! } ! else if (TypeHelper.HasCustomAttribute(mi, typeof (Adapdev.UnitTest.TestFixtureTearDownAttribute)) ! || TypeHelper.HasCustomAttribute(mi, typeof (NUnit.Framework.TestFixtureTearDownAttribute))) ! { ! tf.AddFixtureTearDown(this.BuildBaseTestHelper(mi, tf)); ! } ! else if (TypeHelper.HasCustomAttribute(mi, typeof (Adapdev.UnitTest.TestSetUpAttribute)) ! || TypeHelper.HasCustomAttribute(mi, typeof (Adapdev.UnitTest.SetUpAttribute)) ! || TypeHelper.HasCustomAttribute(mi, typeof (NUnit.Framework.SetUpAttribute)) ! ) ! { ! tf.AddTestSetUp(this.BuildTestHelper(mi, tf)); ! } ! else if (TypeHelper.HasCustomAttribute(mi, typeof (Adapdev.UnitTest.TestTearDownAttribute)) ! || TypeHelper.HasCustomAttribute(mi, typeof (Adapdev.UnitTest.TearDownAttribute)) ! || TypeHelper.HasCustomAttribute(mi, typeof (NUnit.Framework.TearDownAttribute)) ! ) { ! tf.AddTestTearDown(this.BuildTestHelper(mi, tf)); } } } ! // if(this._debugMode) log.Debug(tf.ToString()); return tf; } --- 134,196 ---- ) { ! try ! { ! if(log.IsDebugEnabled) log.Debug("Building TestFixture " + t.FullName); ! // Build the TestFixture ! tf = new Adapdev.UnitTest.Core.TestFixture(); ! tf.Parent = ta; ! tf.Class = t.Name; ! tf.Name = t.Name; ! tf.Namespace = t.Namespace; ! tf.FullName = t.FullName; ! tf.Id = id++; ! this.ProcessCommonAttributes(t, tf); ! foreach (MethodInfo mi in t.GetMethods()) { ! if (TypeHelper.HasCustomAttribute(mi, typeof (Adapdev.UnitTest.TestAttribute)) ! || TypeHelper.HasCustomAttribute(mi, typeof (NUnit.Framework.TestAttribute))) ! { ! if(log.IsDebugEnabled) log.Debug("Building Test " + mi.Name); ! tf.AddTest(this.BuildTest(mi, tf)); ! } ! else if (TypeHelper.HasCustomAttribute(mi, typeof (Adapdev.UnitTest.TestFixtureSetUpAttribute)) ! || TypeHelper.HasCustomAttribute(mi, typeof (NUnit.Framework.TestFixtureSetUpAttribute))) ! { ! if(log.IsDebugEnabled) log.Debug("Building TestFixtureSetUp " + mi.Name); ! tf.AddFixtureSetUp(this.BuildBaseTestHelper(mi, tf)); ! } ! else if (TypeHelper.HasCustomAttribute(mi, typeof (Adapdev.UnitTest.TestFixtureTearDownAttribute)) ! || TypeHelper.HasCustomAttribute(mi, typeof (NUnit.Framework.TestFixtureTearDownAttribute))) ! { ! if(log.IsDebugEnabled) log.Debug("Building TestFixtureTearDown " + mi.Name); ! tf.AddFixtureTearDown(this.BuildBaseTestHelper(mi, tf)); ! } ! else if (TypeHelper.HasCustomAttribute(mi, typeof (Adapdev.UnitTest.TestSetUpAttribute)) ! || TypeHelper.HasCustomAttribute(mi, typeof (Adapdev.UnitTest.SetUpAttribute)) ! || TypeHelper.HasCustomAttribute(mi, typeof (NUnit.Framework.SetUpAttribute)) ! ) ! { ! if(log.IsDebugEnabled) log.Debug("Building TestSetUp " + mi.Name); ! tf.AddTestSetUp(this.BuildTestHelper(mi, tf)); ! } ! else if (TypeHelper.HasCustomAttribute(mi, typeof (Adapdev.UnitTest.TestTearDownAttribute)) ! || TypeHelper.HasCustomAttribute(mi, typeof (Adapdev.UnitTest.TearDownAttribute)) ! || TypeHelper.HasCustomAttribute(mi, typeof (NUnit.Framework.TearDownAttribute)) ! ) ! { ! if(log.IsDebugEnabled) log.Debug("Building TestTearDown " + mi.Name); ! tf.AddTestTearDown(this.BuildTestHelper(mi, tf)); ! } } + if(log.IsDebugEnabled) log.Debug(tf.ToString()); + } + catch(Exception ex) + { + log.Error("Problem loading TestFixture", ex); } } ! return tf; } *************** *** 186,189 **** --- 210,215 ---- this.ProcessMaxKAttribute(m, t); this.ProcessMinOperationsPerSecondAttribute(m, t); + + if(log.IsDebugEnabled) log.Debug("Test built: " + t.ToString()); return t; } *************** *** 343,352 **** } ! private Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args) { string lostNamespace = args.Name.Split((",").ToCharArray())[0]; string lostAssemblyFilename = Path.Combine(Environment.CurrentDirectory, lostNamespace + ".dll"); ! // if(this._infoMode) log.Info("Searching for: " + lostAssemblyFilename); ! return Assembly.LoadFile(lostAssemblyFilename); } --- 369,382 ---- } ! public Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args) { string lostNamespace = args.Name.Split((",").ToCharArray())[0]; string lostAssemblyFilename = Path.Combine(Environment.CurrentDirectory, lostNamespace + ".dll"); ! ! if(log.IsInfoEnabled)log.Info("Not found. Trying to resolve " + lostAssemblyFilename); ! Assembly a = Assembly.LoadFile(lostAssemblyFilename); ! if(a != null && log.IsInfoEnabled) log.Info("Found. Loaded " + a.GetName().Name + " - " + a.GetName().Version + " - " + a.Location); ! ! return a; } *************** *** 354,358 **** { AssemblyName assemblyName = assembly.GetName(); ! // if(this._infoMode) log.Info("Probing for: " + assemblyName); if (! dependencyList.Contains(assemblyName.FullName)) { --- 384,388 ---- { AssemblyName assemblyName = assembly.GetName(); ! if(log.IsInfoEnabled) log.Info("Probing for: " + assemblyName); if (! dependencyList.Contains(assemblyName.FullName)) { *************** *** 365,368 **** --- 395,403 ---- } } + + public void CurrentDomain_AssemblyLoad(object sender, AssemblyLoadEventArgs args) + { + if(log.IsInfoEnabled) log.Info("Loading: " + args.LoadedAssembly.FullName); + } } } \ No newline at end of file Index: LocalTestEngine.cs =================================================================== RCS file: /cvsroot/adapdev/Adapdev/src/Adapdev.UnitTest.Core/LocalTestEngine.cs,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** LocalTestEngine.cs 28 Feb 2005 01:32:21 -0000 1.1.1.1 --- LocalTestEngine.cs 23 Apr 2005 04:54:13 -0000 1.2 *************** *** 13,24 **** private TestSuite suite; private AppDomainManager manager; ! private string[] assemblies; private TestEventDispatcher dispatcher = null; ! public LocalTestEngine(params string[] assemblies) { manager = new AppDomainManager(); ! manager.AddAssemblies(assemblies); ! this.assemblies = assemblies; } --- 13,24 ---- private TestSuite suite; private AppDomainManager manager; ! private string assembly; private TestEventDispatcher dispatcher = null; ! public LocalTestEngine(string assembly) { manager = new AppDomainManager(); ! manager.AddAssemblies(this.assembly); ! this.assembly = assembly; } *************** *** 26,30 **** { TestRunner tr = new TestRunner(); ! this.suite = tr.BuildSuite(assemblies); if(this.dispatcher != null) tr.SetTestEventDispatcher(this.dispatcher); return tr.Run(suite); --- 26,30 ---- { TestRunner tr = new TestRunner(); ! this.suite = tr.BuildSuite(assembly); if(this.dispatcher != null) tr.SetTestEventDispatcher(this.dispatcher); return tr.Run(suite); *************** *** 48,58 **** { TestSuiteBuilder builder = new TestSuiteBuilder(); ! return builder.BuildAssemblies(this.assemblies); } public TestAssembly GetTestAssembly() { ! // TODO ! return null; } --- 48,58 ---- { TestSuiteBuilder builder = new TestSuiteBuilder(); ! return builder.BuildAssemblies(this.assembly); } public TestAssembly GetTestAssembly() { ! TestSuiteBuilder builder = new TestSuiteBuilder(); ! return builder.BuildAssembly(this.assembly); } |