oksyque
oksyque

Reputation: 1

How to parallelize Gauge at specification level?

I'm building a Gauge automation project with Selenium, Maven and Java. When executing a specification with an included table data like

# Specification

| name |
| A |
| B |
| C |

## Scenario 1
* User logs in application

## Scenario 2
* User does something for product <name> 

In single thread, it runs:

mvn clean install
Output: 
Scenario 1
Scenario 2 for name A
Scenario 2 for name B
Scenario 2 for name C

And then it moves to the next specification. However, Gauge behaves different when running the same spec in parallel on 2 nodes:

mvn clean install -DinParallel=true -Dnodes=2
Output:
Browser 1: Scenario 1
Browser 2: Scenario 2 for name A
Browser 1: Scenario 2 for name B
Browser 2: Scenario 2 for name C

You can immediately see that the scenarios from Browser 2 will not succeed as the "precondition" from Scenario 1 was not run.

Is there a way to parallelize Gauge at specification level?

Note: I know that rewriting the scenarios to be self-contained is one way to go, but these tests get really long, really fast and increase the running time.

Upvotes: 0

Views: 1106

Answers (1)

oksyque
oksyque

Reputation: 1

After some experimenting, it turns out that Gauge has 2 different parallelizations, depending on how you write the spec. With a spec with test data like

# Specification

| name |
| A |
| B |
| C |

## Scenario 1
* User logs in application

## Scenario 2
* User does something for product <name> 

the parallelization is done at scenario level, as described in the original question:

mvn clean install -DinParallel=true -Dnodes=2
Output:
Browser 1: Scenario 1
Browser 2: Scenario 2 for name A
Browser 1: Scenario 2 for name B
Browser 2: Scenario 2 for name C

However, when rewriting the specification to incorporate the test data into the steps

# Specification

## Scenario 1
* User logs in application

## Scenario 2 for A
* User does something for product "A"  

## Scenario 2 for B
* User does something for product "B"  

## Scenario 2 for C
* User does something for product "C"

the output looks something like

mvn clean install -DinParallel=true -Dnodes=2
Output:
Browser 1: Scenario 1
Browser 1: Scenario 2 for name A
Browser 1: Scenario 2 for name B
Browser 1: Scenario 2 for name C

which effectively applies parallelization at spec level rather than scenario level.

Upvotes: 0

Related Questions