0

I have two junit test suites, First one will be AllTestInParallel and implemented it to run in multiple threads. Second one is AllTestsInSequence which is quite slower and I need to run in single thread. Finally I need to start both test suites at once. My intention is to run slow tests in first and then run fast test or vise versa.

  @RunWith(MultiThreadedClasspathRunner.class)
  public class AllTestsInParallel { 
  }

  public class MultiThreadedClasspathRunner extends Suite {
  public MultiThreadedClasspathRunner(Class<?> klass, RunnerBuilder builder)    throws InitializationError {
    super(builder, MultiThreadedClasspathRunner.getTestClassesInProjectClassPath(klass));
  }
  ......
  }

  @RunWith(SingleThreadedClasspathRunner.class)
  public class AllTestsInSequence { 
  }

  public class SingleThreadedClasspathRunnerextends Suite {
  public SingleThreadedClasspathRunner(Class<?> klass, RunnerBuilder builder)    throws InitializationError {
    super(builder, SingleThreadedClasspathRunner.getTestClassesInProjectClassPath(klass));
  }
  ......
  }

Can anyone let me know to initiate both runners at once? I tried using jvm param '-Dtest' as below;

     -Dtest=com.selenium.runner.AllTestsInSequence,com.selenium.runner.AllTestsInParallel

But it always get last value and execute. Is it possible to start one after other in one command?

JagKum
  • 183
  • 2
  • 18

1 Answers1

1

Use the @Suiteannotation to create a new suite containing both of the suites you want to run:

@RunWith(Suite.class)
@Suite.SuiteClasses({
   AllTestsInParallel.class,
   AllTestsInSequence .class
})
public class AllTestsSuite {   
}
JDC
  • 4,247
  • 5
  • 31
  • 74