0

I have two FitNesse suits which are mutually exclusive and I want to run them in parallel.

As they are invoked from a junit test case, I have written the following piece of code:

@Test
public void executeFitnesseSuites() {
    final Class<?>[] classes = { Suite1.class, Suite2.class };
    final Result result = JUnitCore.runClasses(ParallelComputer.classes(), classes);
    System.out.println(result);

}

@RunWith(FitNesseRunner.class)
@FitNesseRunner.Suite("Suite1")
@FitNesseRunner.FitnesseDir(".")
@FitNesseRunner.OutputDir("/tmp/fitnesse/")
public static class Suite1{

}

@RunWith(FitNesseRunner.class)
@FitNesseRunner.Suite("Suite2")
@FitNesseRunner.FitnesseDir(".")
@FitNesseRunner.OutputDir("/tmp/fitnesse/")
public static class Suite2{

}

In the earlier implementation, these were two independent classes and were being executed sequentially.

However, I am seeing a similar execution time for the above test.

Does this mean that FitNesse is not spinning up two slim server instances and executing these suites in parallel?

n-verbitsky
  • 552
  • 2
  • 9
  • 20
Darshan Mehta
  • 30,102
  • 11
  • 68
  • 102

1 Answers1

0

Unfortunately FitNesse itself is not thread safe, so one should not run two slim server instances in one JVM at the same time.

I'm not sure how jUnit behaves using the approach you use. Does it spin up two parallel JVMs, or just threads in the same JVM?

An approach I've used in the past to run two completely independent suites with jUnit is two have two separate classes (as you had before) and run these in parallel on separate JVMs using Maven's failsafe plugin. Failsafe (and surefire as well) offers a forkCount property to specify the number of processes to use (see http://maven.apache.org/surefire/maven-failsafe-plugin/examples/fork-options-and-parallel-execution.html for more details). Please note that you should NOT use the parallel property as that is within one JVM.

If you are running tests in parallel using FitNesse's jUnit runner you may also be interested in a tool I created to combine the HTML reports of such runs into a single report: HtmlReportIndexGenerator. This is part my fixtures jar, but also available as separate docker image: hsac/fitnesse-fixtures-combine.

Fried Hoeben
  • 3,247
  • 16
  • 14
  • thanks for the reply @FriedHoeben. For junit, it spawns two threads in the same JVM for two tests. For the approach you mentioned above, if I create two separate classes for two suites then they will be executed sequentially by `CI` environment and hence, I would lose the advantage of concurrency, hence the above approach. Let me have a look at `failsafe` plugin btw. – Darshan Mehta Feb 03 '20 at 11:29
  • The point of my remark is that if you run your tests (in the CI environment) using surefire or failsafe you can instruct it to run multiple JVMs so the tests are not run sequentially but in parallel... – Fried Hoeben Feb 03 '20 at 14:57
  • I have tried the above approach and it seems to work so far. However, I am now getting intermittent test failures with fitnesse. Is there any way (for fitnesse tests being executed from junit) to retry the failing tests before marking them as failed? The failing tests pass when I execute those again. – Darshan Mehta Feb 12 '20 at 10:31
  • Not directly from jUnit, I think. It does generate a rerun wiki page which can be run to retry the failed tests. I use that in my docker containers – Fried Hoeben Feb 12 '20 at 10:35