[Adapdev-commits] Adapdev/src/Adapdev.UnitTest.Core AbstractTest.cs,1.6,1.7 RunTestCommand.cs,1.6,1.
Status: Beta
Brought to you by:
intesar66
From: Sean M. <int...@us...> - 2005-11-27 06:32:51
|
Update of /cvsroot/adapdev/Adapdev/src/Adapdev.UnitTest.Core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27953/src/Adapdev.UnitTest.Core Modified Files: AbstractTest.cs RunTestCommand.cs RunTestFixtureCommand.cs RunTestIterationCommand.cs TestState.cs Log Message: Fixed bug w/ dataschema saving and comparison Fixed bugs w/ test multi-threading Index: AbstractTest.cs =================================================================== RCS file: /cvsroot/adapdev/Adapdev/src/Adapdev.UnitTest.Core/AbstractTest.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** AbstractTest.cs 16 Nov 2005 07:01:53 -0000 1.6 --- AbstractTest.cs 27 Nov 2005 06:32:43 -0000 1.7 *************** *** 49,53 **** protected int _sequence = 0; protected int _id = 0; - protected bool _threads = false; protected bool _repeat = false; protected int _repeatCount = 1; --- 49,52 ---- *************** *** 74,83 **** } - public bool MultiThreaded - { - get { return this._threads; } - set { this._threads = value; } - } - public bool Repeat { --- 73,76 ---- Index: RunTestFixtureCommand.cs =================================================================== RCS file: /cvsroot/adapdev/Adapdev/src/Adapdev.UnitTest.Core/RunTestFixtureCommand.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** RunTestFixtureCommand.cs 23 Nov 2005 03:00:42 -0000 1.5 --- RunTestFixtureCommand.cs 27 Nov 2005 06:32:43 -0000 1.6 *************** *** 25,28 **** --- 25,29 ---- { this._dispatcher = dispatcher; + //if(tf.IsMultiThreaded) this._dispatcher = null; this._testFixture = tf; this._assembly = assembly; *************** *** 33,59 **** public void Execute() { ! if(_dispatcher != null)_dispatcher.OnTestFixtureStarted(new TestFixtureEventArgs(this._testFixture)); ! for (int j = 1; j <= this._testFixture.RepeatCount; j++) { ! this._type = null; ! this._testFixtureIteration = null; ! if (this._testFixture.RepeatDelay > 0) Thread.Sleep(this._testFixture.RepeatDelay); ! this._testFixtureIteration = new TestFixtureIteration(); ! if(_dispatcher != null)this._dispatcher.OnTestFixtureIterationStarted(new TestFixtureEventArgs(this._testFixture)); ! this._o = this._assembly.CreateInstance(this._className); ! this._type = this._assembly.GetType(this._className, true); ! this.RunTestFixtureSetUps(this._testFixture, this._o, this._type); ! RunTests(); ! this.RunTestFixtureTearDowns(this._testFixture, this._o, this._type); ! this._testFixtureIteration.Iteration = j; ! this._testFixtureResult.AddIteration(this._testFixtureIteration); ! if(_dispatcher != null)_dispatcher.OnTestFixtureIterationCompleted(new TestFixtureIterationEventArgs(this._testFixtureIteration)); } - if(_dispatcher != null)_dispatcher.OnTestFixtureCompleted(new TestFixtureResultEventArgs(this._testFixtureResult)); } --- 34,63 ---- public void Execute() { ! if (!this._testFixture.Ignore && this._testFixture.ShouldRun) { ! if(_dispatcher != null && !_testFixture.IsMultiThreaded)_dispatcher.OnTestFixtureStarted(new TestFixtureEventArgs(this._testFixture)); ! for (int j = 1; j <= this._testFixture.RepeatCount; j++) ! { ! this._type = null; ! this._testFixtureIteration = null; ! if (this._testFixture.RepeatDelay > 0) Thread.Sleep(this._testFixture.RepeatDelay); ! this._testFixtureIteration = new TestFixtureIteration(); ! if(_dispatcher != null)this._dispatcher.OnTestFixtureIterationStarted(new TestFixtureEventArgs(this._testFixture)); ! this._o = this._assembly.CreateInstance(this._className); ! this._type = this._assembly.GetType(this._className, true); ! this.RunTestFixtureSetUps(this._testFixture, this._o, this._type); ! RunTests(); ! this.RunTestFixtureTearDowns(this._testFixture, this._o, this._type); ! this._testFixtureIteration.Iteration = j; ! this._testFixtureResult.AddIteration(this._testFixtureIteration); ! if(_dispatcher != null)_dispatcher.OnTestFixtureIterationCompleted(new TestFixtureIterationEventArgs(this._testFixtureIteration)); ! } ! if(_dispatcher != null)_dispatcher.OnTestFixtureCompleted(new TestFixtureResultEventArgs(this._testFixtureResult)); } } *************** *** 102,146 **** RunTestCommand command = new RunTestCommand(this._dispatcher, test, this._testFixture, this._type, this._o, this._testFixtureIteration); Thread t = new Thread(new ThreadStart(command.Execute)); threads.Add(t); t.Start(); } ! foreach(Thread t in threads) t.Join(); ! ! ! // using(ThreadPoolWait threadPool = new ThreadPoolWait()) ! // { ! // foreach (Test test in this._testFixture.GetTests()) ! // { ! // RunTestCommand command = new RunTestCommand(this._dispatcher, test, this._testFixture, this._type, this._o, this._testFixtureIteration); ! // threadPool.QueueUserWorkItem(new WaitCallback(command.Execute)); ! // } ! // threadPool.WaitOne(); ! // } - // SmartThreadPool smartThreadPool = new SmartThreadPool(); - // - // try - // { - // ArrayList workitems = new ArrayList(); - // - // foreach(Test test in this._testFixture.GetTests()) - // { - // RunTestCommand command = new RunTestCommand(this._dispatcher, test, this._testFixture, this._type, this._o, this._testFixtureIteration); - // workitems.Add(smartThreadPool.QueueWorkItem(new WorkItemCallback(command.Execute))); - // } - // - // workitems.TrimToSize(); - // IWorkItemResult[] results = workitems.ToArray(typeof(IWorkItemResult)) as IWorkItemResult[]; - // SmartThreadPool.WaitAll(results, 15000, true); - // } - // catch(Exception ex) - // { - // Console.WriteLine(ex.Message); - // Console.WriteLine(ex.StackTrace); - // } - // finally - // { - // smartThreadPool.Shutdown(); - // } } else --- 106,116 ---- RunTestCommand command = new RunTestCommand(this._dispatcher, test, this._testFixture, this._type, this._o, this._testFixtureIteration); Thread t = new Thread(new ThreadStart(command.Execute)); + t.IsBackground = true; + t.Priority = ThreadPriority.Highest; threads.Add(t); t.Start(); } ! foreach(Thread t in threads) t.Join(30000); } else Index: TestState.cs =================================================================== RCS file: /cvsroot/adapdev/Adapdev/src/Adapdev.UnitTest.Core/TestState.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** TestState.cs 16 Nov 2005 07:01:53 -0000 1.4 --- TestState.cs 27 Nov 2005 06:32:43 -0000 1.5 *************** *** 46,50 **** { Untested = 1, ! // NotRun = 2, Pass = 4, Ignore = 8, --- 46,50 ---- { Untested = 1, ! NotRun = 2, Pass = 4, Ignore = 8, Index: RunTestCommand.cs =================================================================== RCS file: /cvsroot/adapdev/Adapdev/src/Adapdev.UnitTest.Core/RunTestCommand.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** RunTestCommand.cs 26 Nov 2005 08:09:23 -0000 1.6 --- RunTestCommand.cs 27 Nov 2005 06:32:43 -0000 1.7 *************** *** 30,38 **** private object o = null; private TestFixtureIteration _testFixtureIteration = null; - private readonly SmartThreadPool pool; public RunTestCommand(TestEventDispatcher dispatcher, Test test, TestFixture tf, Type type, object o, TestFixtureIteration tfi) { this._dispatcher = dispatcher; this._test = test; this._testFixture = tf; --- 30,38 ---- private object o = null; private TestFixtureIteration _testFixtureIteration = null; public RunTestCommand(TestEventDispatcher dispatcher, Test test, TestFixture tf, Type type, object o, TestFixtureIteration tfi) { this._dispatcher = dispatcher; + //if(test.IsMultiThreaded || tf.IsMultiThreaded) this._dispatcher = null; this._test = test; this._testFixture = tf; *************** *** 42,56 **** } - public RunTestCommand(TestEventDispatcher dispatcher, Test test, TestFixture tf, Type type, object o, TestFixtureIteration tfi, SmartThreadPool pool) - { - this._dispatcher = dispatcher; - this._test = test; - this._testFixture = tf; - this.o = o; - this._testFixtureIteration = tfi; - this.pool = pool; - this._type = type; - } - public void Execute() { --- 42,45 ---- *************** *** 94,98 **** private void RunTestIteration(TestResult testResult, MethodInfo method) { ! if(this._testFixture.IsMultiThreaded && this.pool != null) { ArrayList threads = new ArrayList(); --- 83,87 ---- private void RunTestIteration(TestResult testResult, MethodInfo method) { ! if(this._testFixture.IsMultiThreaded) { ArrayList threads = new ArrayList(); *************** *** 105,136 **** t.Start(); } ! foreach(Thread t in threads) t.Join(); ! ! // try ! // { ! // ArrayList workitems = new ArrayList(); ! // ! // for (int i = 1; i <= _test.RepeatCount; i++) ! // { ! // RunTestIterationCommand command = new RunTestIterationCommand(this._dispatcher, this._test, this._testFixture, this._type, this.o, this._testFixtureIteration, method, i, testResult); ! // workitems.Add(pool.QueueWorkItem(new WorkItemCallback(command.Execute))); ! // } ! // ! // workitems.TrimToSize(); ! // IWorkItemResult[] results = workitems.ToArray(typeof(IWorkItemResult)) as IWorkItemResult[]; ! // ! // SmartThreadPool.WaitAll(results, 15000, true); ! // } ! // catch(Exception ex) ! // { ! // Console.WriteLine(ex.Message); ! // Console.WriteLine(ex.StackTrace); ! // } ! } else { ! for (int i = 1; i <= _test.RepeatCount; i++) { ! new RunTestIterationCommand(this._dispatcher, this._test, this._testFixture, this._type, this.o, this._testFixtureIteration, method, i, testResult).Execute(); } } --- 94,107 ---- t.Start(); } ! foreach(Thread t in threads) t.Join(30000); ! } else { ! if(this._test.ShouldRun) { ! for (int i = 1; i <= _test.RepeatCount; i++) ! { ! new RunTestIterationCommand(this._dispatcher, this._test, this._testFixture, this._type, this.o, this._testFixtureIteration, method, i, testResult).Execute(); ! } } } Index: RunTestIterationCommand.cs =================================================================== RCS file: /cvsroot/adapdev/Adapdev/src/Adapdev.UnitTest.Core/RunTestIterationCommand.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** RunTestIterationCommand.cs 23 Nov 2005 03:00:42 -0000 1.6 --- RunTestIterationCommand.cs 27 Nov 2005 06:32:43 -0000 1.7 *************** *** 181,186 **** ti.TraceOutput = traceWriter.ToString(); ! lock(this){tr.AddIteration(ti);} ! if(_dispatcher != null)_dispatcher.OnTestIterationCompleted(new TestIterationEventArgs(ti)); Console.SetOut(consoleOut); --- 181,189 ---- ti.TraceOutput = traceWriter.ToString(); ! lock(this) ! { ! tr.AddIteration(ti); ! if(_dispatcher != null)_dispatcher.OnTestIterationCompleted(new TestIterationEventArgs(ti)); ! } Console.SetOut(consoleOut); |