-1

I had implemented Cucumber 4.2 parallel execution for chrome browser only.Now, I want to implement parallel execution for two browsers (Firefox/Chrome). Please provide an example or skeleton so that i can improve from it. Besides, where to search for Cucumber API javadoc?

Chrome Runner:

public class ChromeTestNGParallel {

    @Test
    public void execute() {
        //Main.main(new String[]{"--threads", "4", "-p", "timeline:target/cucumber-parallel-report", "-g", "com.peterwkc.step_definitions", "src/main/features"});
        String [] argv = new String[]{"--threads", "8", "-p", "timeline:target/cucumber-parallel-report", "-g", "com.peterwkc.step_definitions", "src/main/features"};
        ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
        byte exitstatus = Main.run(argv, contextClassLoader);
    }

}

Firefox Runner:

public class FirefoxTestNGParallel {

    @Test
    public void execute() {
        //Main.main(new String[]{"--threads", "4", "-p", "timeline:target/cucumber-parallel-report", "-g", "com.peterwkc.step_definitions", "src/main/features"});
        String [] argv = new String[]{"--threads", "8", "-p", "timeline:target/cucumber-parallel-report", "-g", "com.peterwkc.step_definitions", "src/main/features"};
        ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
        byte exitstatus = Main.run(argv, contextClassLoader);
    }

}

This is what I want. Cucumber_Design

nicholas
  • 2,581
  • 14
  • 66
  • 104
  • I got no experience at all. I don't know whether this function is implemented by someone already. I not asking somebody to do the job for me. – nicholas Nov 18 '18 at 03:02
  • I have try to create two runner class, one called ChromeRunner and called Firefox Runner. I"m only can execute one runner at a time using TestNG. How to run it using maven? I'm new to Maven. – nicholas Nov 19 '18 at 10:44
  • I think i got the answers already by creating testng.xml and execute them as suite in Intellij. – nicholas Nov 19 '18 at 11:07

1 Answers1

0

I think you can do this outside Cucumber.

The first part is to configure Cucumber to run with a particular browser using either a command line parameter or the environment.

The second part is to run two (or more cucumber instances at the same time). Basically use virtual machines to do this just run cucumber with different command line parameters to configure the browser.

You could even use a paid service like Circle CI to do this for you.

diabolist
  • 3,990
  • 1
  • 11
  • 15
  • I prefer to use Cucumber to implement parallel and Jenkins for CI. I don't want two Cucumber instances though it is a very good idea. What is the purposes of two cucumber instances instead of one? – nicholas Nov 20 '18 at 08:58
  • @peterwkc the purpose is to not bloat your codebase with unnecessary parallelisation code. You would have to essentially re-write your code, or cucumber to achieve true parallel tests without using an external script, and so the easiest option is to tackle it from that higher level – KyleFairns Nov 20 '18 at 09:23
  • Can you provide a concrete example or link on how to implement Cucumber parallelisation from high level? Thanks. – nicholas Nov 20 '18 at 13:29
  • Can you provide the Maven command to run two Cucumber instances for different browsers? – nicholas Nov 21 '18 at 08:47
  • No thats something you will have to do. I don't use Maven or Java, I cuke with ruby. I don't think Maven is the solution, thats for managing dependencies. – diabolist Nov 21 '18 at 12:05
  • How you do it with Ruby? Can you elaborate? – nicholas Nov 22 '18 at 09:43
  • I'd use multiple VM's or perhaps use a CI service like Semaphore or CircleCI. However I don't need to this sort of thing as my Cukes on all my projects tend to run quite quickly (< 10 mins for everything). So i'd just have a separate CI chain and run things serially every so often. – diabolist Nov 22 '18 at 16:11
  • Personally, I use bash for my high level parallelisation. You can do it with a simple script that takes something like: ` & ` etc, and carries it on. The one I use is a bit more advanced than that, but if you give it a go yourself and get stuck, feel free to ask another question on it, and I'll be happy to help you with your problems with it. – KyleFairns Nov 23 '18 at 16:03