To start, since this is probably going to be a long thread, will state how the 
test cases work using the benchmark decorators.

ThreadLocalDecorator (and all the other decorators that accept number of 
threads and loops) - for each thread specified in the number of threads, there 
will be a new instance of the test created.  For the number of loops specified, 
the test methods will be called on each test instance.  So for example, if 
specify 3 threads and 10 loops, there will be three instances of the test class 
created and each instance will have their test methods called 10 times by each 
of their respective threads.  An example class that demonstrates this would be:

public class SimpleThreadLoopCounter extends TestCase
{
   private static int staticCounter = 0;
   private static int staticMethodCounter = 0;
   private int localCounter = 0;

   public static Test suite()
   {
      return new ThreadLocalDecorator(SimpleThreadLoopCounter.class, 3, 10, 0, 
true, true);
   }

   public SimpleThreadLoopCounter()
   {
      staticCounter++;
   }

   public void testCounter() throws Exception
   {
      System.out.println("staticCounter = " + staticCounter);
      System.out.println("staticMethodcounter = " + ++staticMethodCounter);
      System.out.println("localCounter = " + ++localCounter);
   }
}

When this is run, the last entry will be:

staticCounter = 3
staticMethodcounter = 30
localCounter = 10

Also, important to note that JUnit will create a new instance of the TestCase 
for each test method it calls.  So using the same sample above, if copied the 
testCounter method and called it testCounter2, the output would be:

staticCounter = 6
staticMethodcounter = 60
localCounter = 10

This means that eventhough local variables can be reused for each loop, they 
will be thrown away for each new test method run.  

Having said all this will follow up with another post of where, if anywhere, 
this behavior should be changed.



View the original post : 
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3874158#3874158

Reply to the post : 
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3874158


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
JBoss-Development mailing list
JBoss-Development@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to