martinschneider / justtestlah

Dynamic test framework for web and mobile applications
Apache License 2.0
47 stars 20 forks source link

Support parallel execution #141

Open aman13garg opened 3 years ago

aman13garg commented 3 years ago

Hi @martinschneider I would like to know that do we support running tests in parallel on mobile. If yes then do let me know what's need to be done or if not then do let me know how we can achieve it . is there any possibility for same ?

martinschneider commented 3 years ago

Hi @aman13garg! Thank you for the request!

Parallel execution should already work with Cucumber as described here. I need a bit more time to understand why this doesn't work with JustTestLah!.

I'm also considering supporting TestNG in the next release which will allow better parallelization support with Cucumber (i.e. on scenario level instead of feature level).

martinschneider commented 3 years ago

I found the issue. Parallel execution of tests is achieved by the Maven surefire or failsafe plugins. Both of them don't work with junit-vintage-engine which is needed to support JUnit 5 assertions in Cucumber. I've raised a bug for this: https://issues.apache.org/jira/browse/SUREFIRE-1918 (see also https://github.com/cucumber/cucumber-jvm/issues/2311).

There is an easy workaround! If you don't need JUnit 5, simply exclude org.junit.vintage:junit-vintage-engine from the Maven dependency in your pom.xml:

<dependency>
  <groupId>qa.justtestlah</groupId>
  <artifactId>justtestlah-core</artifactId>
  <version>${project.version}</version>
  <exclusions>
    <exclusion>
      <groupId>org.junit.vintage</groupId>
      <artifactId>junit-vintage-engine</artifactId>
    </exclusion>
  </exclusions>
</dependency>

Then parallel execution can be achieved by adding this configuration:

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
          <parallel>methods</parallel>
          <useUnlimitedThreads>true</useUnlimitedThreads>
        </configuration>
      </plugin>
      ...
  </plugins>
</build>

Have a look at https://github.com/martinschneider/justtestlah/pull/154. It still needs a bit of work and cleaning up but you can already use it do run tests in parallel. This will be fully supported and documented in release 1.10.