title: how to initialize JUnit test classes before running in parallel
body: <p>I am trying to execute JUnit tests in parallel using the <a href="http://junit.org/junit4/javadoc/4.12/org/junit/experimental/ParallelComputer.html" rel="nofollow noreferrer">ParallelComputer</a> experimental feature, however I do not know how to pre-initialize each of the test classes before kicking off the tests.</p>
  
  <p>The classic example of how these are supposed to be used is as follows (as shown in the following GitHub <a href="https://gist.github.com/djangofan/4997487" rel="nofollow noreferrer">link</a>).  Per the example, how do I initialize the <code>ParallelTest1</code> and <code>ParallelTest2</code> classes with shared data before starting the parallel thread testing.  I was able to do this via constructors in each of the classes, however I need to make sure that both classes are fully initialized before the run starts.  This problem is probably not specific to the Parallel nature of how I wish to perform the testing but more likely how to use some special keywords to order prevent initialized objects from starting until required.  Ideally the example <code>ParallelComputerTest</code> could have this shared data initialized in its constructor, however in that case, how could the nested static parallel test classes get access to this instance data?</p>
  
  <pre><code>public class ParallelComputerTest {  
  
     @Test  
      public void test() {      
        Class[] cls={ParallelTest1.class,ParallelTest2.class };  
  
        //Parallel among classes  
        JUnitCore.runClasses(ParallelComputer.classes(), cls);  
  
        //Parallel among methods in a class  
        JUnitCore.runClasses(ParallelComputer.methods(), cls);  
  
        //Parallel all methods in all classes  
        JUnitCore.runClasses(new ParallelComputer(true, true), cls);     
      }  
     public static class ParallelTest1{  
        @Test public void a(){}  
        @Test public void b(){}  
     }  
     public static class ParallelTest2{  
        @Test public void a(){}  
        @Test public void b(){}  
     }  
  }
  </code></pre>