[Adapdev-commits] Adapdev/src/Adapdev.UnitTest.Core AbstractTest.cs,1.1.1.1,1.2 Adapdev.UnitTest.Cor
Status: Beta
Brought to you by:
intesar66
From: Sean M. <int...@us...> - 2005-04-14 03:32:15
|
Update of /cvsroot/adapdev/Adapdev/src/Adapdev.UnitTest.Core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29338/src/Adapdev.UnitTest.Core Modified Files: AbstractTest.cs Adapdev.UnitTest.Core.csproj TestRunner.cs TestSuiteBuilder.cs TextFormatter.cs Log Message: Revisions for Zanebug v1.5 Index: TestSuiteBuilder.cs =================================================================== RCS file: /cvsroot/adapdev/Adapdev/src/Adapdev.UnitTest.Core/TestSuiteBuilder.cs,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** TestSuiteBuilder.cs 28 Feb 2005 01:32:23 -0000 1.1.1.1 --- TestSuiteBuilder.cs 14 Apr 2005 03:32:05 -0000 1.2 *************** *** 39,42 **** --- 39,43 ---- using System.IO; using System.Reflection; + using log4net; using NUnit.Framework; *************** *** 46,51 **** --- 47,57 ---- public class TestSuiteBuilder : MarshalByRefObject { + // unique id for the specified test private int id = 0; + // list of assembly dependencies for the current assembly private Hashtable dependencyList = new Hashtable(); + // create the logger + private static readonly ILog log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + // setup the logging levels public TestSuite BuildAssemblies(params string[] assemblies) *************** *** 67,79 **** --- 73,98 ---- public TestAssembly BuildAssembly(string assemblyName) { + // set delegate to probe for an assembly when it's not found in the base path AppDomain.CurrentDomain.AssemblyResolve +=new ResolveEventHandler(CurrentDomain_AssemblyResolve); + // switch the current directory to the assemblies location + // needed to find related files for the specified assembly FileInfo fi = new FileInfo(assemblyName); string orig = Environment.CurrentDirectory; Environment.CurrentDirectory = fi.DirectoryName; + if(log.IsInfoEnabled) + { + log.Info("Building assembly: " + assemblyName); + log.Info("Environment Directory: " + orig); + log.Info("Assembly Directory: " + fi.DirectoryName); + } + + // add the assembly to the AssemblyCache Assembly assembly = AssemblyCache.Add(assemblyName.ToLower(), assemblyName); + // find any assembly dependencies this.FindDependencies(assembly, dependencyList); + // Build the TestAssembly information TestAssembly ta = new TestAssembly(); ta.AssemblyName = fi.Name; *************** *** 85,88 **** --- 104,108 ---- ta.Id = id++; + // Build the TestFixtures foreach (Type t in assembly.GetExportedTypes()) { *************** *** 90,94 **** --- 110,117 ---- } + // restore the original environment Environment.CurrentDirectory = orig; + // if(this._debugMode) log.Debug(ta.ToString()); + return ta; } *************** *** 101,104 **** --- 124,128 ---- ) { + // Build the TestFixture tf = new Adapdev.UnitTest.Core.TestFixture(); tf.Parent = ta; *************** *** 106,109 **** --- 130,134 ---- tf.Name = t.Name; tf.Namespace = t.Namespace; + tf.FullName = t.FullName; tf.Id = id++; *************** *** 143,146 **** --- 168,172 ---- } } + // if(this._debugMode) log.Debug(tf.ToString()); return tf; } *************** *** 152,155 **** --- 178,182 ---- t.Method = m.Name; t.Name = m.Name; + t.FullName = tf.FullName + "." + m.Name; t.Id = id++; this.ProcessTestAttribute(m, t); *************** *** 320,323 **** --- 347,351 ---- 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); } *************** *** 326,329 **** --- 354,358 ---- { AssemblyName assemblyName = assembly.GetName(); + // if(this._infoMode) log.Info("Probing for: " + assemblyName); if (! dependencyList.Contains(assemblyName.FullName)) { Index: TestRunner.cs =================================================================== RCS file: /cvsroot/adapdev/Adapdev/src/Adapdev.UnitTest.Core/TestRunner.cs,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** TestRunner.cs 28 Feb 2005 01:32:22 -0000 1.1.1.1 --- TestRunner.cs 14 Apr 2005 03:32:05 -0000 1.2 *************** *** 43,46 **** --- 43,47 ---- using Adapdev; using Adapdev.Diagnostics; + using log4net; public delegate double ThreadedTestHandler(MethodInfo method, object o); *************** *** 55,61 **** private TestEventDispatcher _dispatcher = null; - private RunMode _mode = RunMode.NotRunning; /// <summary> /// The list of assemblies to load --- 56,67 ---- private TestEventDispatcher _dispatcher = null; private RunMode _mode = RunMode.NotRunning; + // create the logger + private static readonly ILog log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + // setup the logging levels + private bool _debugMode = log.IsDebugEnabled; + private bool _infoMode = log.IsInfoEnabled; + /// <summary> /// The list of assemblies to load *************** *** 127,130 **** --- 133,138 ---- tar.Location = ta.Location; + // if(this._debugMode) log.Debug("Running TA " + ta.Name); + if(_dispatcher != null) _dispatcher.OnTestAssemblyStarted(new TestAssemblyEventArgs(ta)); for (int i = 1; i <= ta.RepeatCount; i++) *************** *** 160,163 **** --- 168,173 ---- Assembly a = AssemblyCache.Get(tf.Parent.OriginalPath); + // if(this._debugMode) log.Debug("Running TF " + tf.Name); + if(_dispatcher != null)_dispatcher.OnTestFixtureStarted(new TestFixtureEventArgs(tf)); for (int j = 1; j <= tf.RepeatCount; j++) *************** *** 179,182 **** --- 189,194 ---- tr.Description = test.Description; + // if(this._debugMode) log.Debug("Running T " + test.Name); + if (!test.Ignore && test.ShouldRun) { *************** *** 357,361 **** foreach (BaseTestHelper t in tf.GetFixtureSetUps()) { - // Console.WriteLine(t.Method); if(_dispatcher != null)_dispatcher.OnBaseTestHelperStarted(new BaseTestHelperEventArgs(t)); MethodInfo m = type.GetMethod(t.Method); --- 369,372 ---- *************** *** 368,372 **** foreach (BaseTestHelper t in tf.GetFixtureTearDowns()) { - // Console.WriteLine(t.Method); if(_dispatcher != null)_dispatcher.OnBaseTestHelperStarted(new BaseTestHelperEventArgs(t)); MethodInfo m = type.GetMethod(t.Method); --- 379,382 ---- *************** *** 393,397 **** foreach (TestHelper t in tf.GetTestTearDowns()) { - // Console.WriteLine(t.Method); if (t.Test.Length < 1 || t.Test.ToLower().Equals(name.ToLower())) { --- 403,406 ---- Index: Adapdev.UnitTest.Core.csproj =================================================================== RCS file: /cvsroot/adapdev/Adapdev/src/Adapdev.UnitTest.Core/Adapdev.UnitTest.Core.csproj,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Adapdev.UnitTest.Core.csproj 28 Feb 2005 01:55:12 -0000 1.2 --- Adapdev.UnitTest.Core.csproj 14 Apr 2005 03:32:05 -0000 1.3 *************** *** 94,97 **** --- 94,103 ---- AssemblyName = "nunit.framework" HintPath = "..\..\lib\nunit.framework.dll" + Private = "True" + /> + <Reference + Name = "log4net" + AssemblyName = "log4net" + HintPath = "..\..\lib\log4net.dll" /> </References> Index: AbstractTest.cs =================================================================== RCS file: /cvsroot/adapdev/Adapdev/src/Adapdev.UnitTest.Core/AbstractTest.cs,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** AbstractTest.cs 28 Feb 2005 01:32:20 -0000 1.1.1.1 --- AbstractTest.cs 14 Apr 2005 03:32:05 -0000 1.2 *************** *** 58,61 **** --- 58,62 ---- protected TestState _testState = TestState.Untested; protected AbstractTestResult _result = null; + protected string _fullName = String.Empty; public AbstractTest() *************** *** 151,154 **** --- 152,161 ---- } + public string FullName + { + get{return this._fullName;} + set{this._fullName = value;} + } + public abstract int GetTestCount(); } Index: TextFormatter.cs =================================================================== RCS file: /cvsroot/adapdev/Adapdev/src/Adapdev.UnitTest.Core/TextFormatter.cs,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** TextFormatter.cs 28 Feb 2005 01:32:23 -0000 1.1.1.1 --- TextFormatter.cs 14 Apr 2005 03:32:05 -0000 1.2 *************** *** 55,59 **** } ! sb.Append(this.GetSummary(results) + "\r\n"); } --- 55,59 ---- } ! sb.Append(this.GetSummary(results)); } *************** *** 65,75 **** sb.Append("SUMMARY\r\n"); sb.Append("========================================\r\n"); ! return String.Format("Total Failed: {0}\r\n" + ! "Total Passed: {1}\r\n" + ! "Total Ignored: {2}\r\n"+ ! "Percent Passed: {3}\r\n" + ! "Percent Failed: {4}\r\n", ! ts.TotalFailed, ts.TotalPassed, ts.TotalIgnored, ts.PercentPassed.ToString("P"), --- 65,72 ---- sb.Append("SUMMARY\r\n"); sb.Append("========================================\r\n"); ! return String.Format("Passed / Failed / Ignored: {0} / {1} / {2}\r\n" + ! "Percent Passed / Failed: {3} / {4}\r\n", ts.TotalPassed, + ts.TotalFailed, ts.TotalIgnored, ts.PercentPassed.ToString("P"), *************** *** 85,112 **** { Debug.Assert(tar != null); ! foreach(AbstractTestIteration ati in tar.Iterations) { ! if(tar.Iterations.Count > 1) sb.Append(this.GetNesting(nesting) + "Iteration: " + ati.Iteration + "\r\n"); ! sb.AppendFormat(this.GetNesting(nesting + 1) + this.GetMarker(tar) + "{0} - {1}\r\n", tar.Name, tar.State); ! if((tar is TestResult) && ((tar as TestResult).Description.Length > 0)) sb.AppendFormat(this.GetNesting(nesting + 2) + "Description: {0}\r\n", (tar as TestResult).Description); ! ! if(showFailure && (ati is TestIteration)) { ! TestIteration ti = ati as TestIteration; ! if(ti.Result.Length > 0) sb.Append(this.GetOutput("Result: " + this.GetDivider() + ti.Result + "\r\n", nesting + 2)); ! if(ti.FullStackTrace.Length > 0) sb.Append(this.GetOutput("StackTrace: " + this.GetDivider() + ti.FullStackTrace + "\r\n", nesting + 2)); ! } ! if(showOutput && ati.ConsoleOutput.Length > 0) ! { ! sb.Append(this.GetOutput("Output: " + this.GetDivider() + ati.AllOutput, nesting + 2)); ! } ! if(ati is CompositeAbstractTestIteration) ! { ! foreach(AbstractTestResult result in (ati as CompositeAbstractTestIteration).GetTestResults()) ! { ! this.GetDetailedSummary(result, showOutput, showFailure, nesting + 1); } } --- 82,112 ---- { Debug.Assert(tar != null); ! if(!(tar.State == TestState.Ignore)) { ! foreach(AbstractTestIteration ati in tar.Iterations) { ! if(tar.Iterations.Count > 1) sb.Append(this.GetNesting(nesting) + "Iteration: " + ati.Iteration + "\r\n"); ! sb.AppendFormat(this.GetNesting(nesting + 1) + this.GetMarker(tar) + "{0} - {1}\r\n", tar.Name, tar.State); ! if((tar is TestResult) && ((tar as TestResult).Description.Length > 0)) sb.AppendFormat(this.GetNesting(nesting + 2) + "Description: {0}\r\n", (tar as TestResult).Description); ! if(showFailure && (ati is TestIteration)) ! { ! TestIteration ti = ati as TestIteration; ! if(ti.Result.Length > 0) sb.Append(this.GetOutput("Result: " + this.GetDivider() + ti.Result + "\r\n", nesting + 2)); ! if(ti.FullStackTrace.Length > 0) sb.Append(this.GetOutput("StackTrace: " + this.GetDivider() + ti.FullStackTrace + "\r\n", nesting + 2)); ! } ! ! if(showOutput && ati.ConsoleOutput.Length > 0) ! { ! sb.Append(this.GetOutput("Output: " + this.GetDivider() + ati.AllOutput, nesting + 2)); ! } ! if(ati is CompositeAbstractTestIteration) ! { ! foreach(AbstractTestResult result in (ati as CompositeAbstractTestIteration).GetTestResults()) ! { ! this.GetDetailedSummary(result, showOutput, showFailure, nesting + 1); ! } } } |