Search code examples
javamultithreadingmavenkaratescenarios

Scenario Outline not running on multiple threads when tag used


Using Karate V1.4.1...

I've a project with multiple feature files, all of which are data-driven (Scenario Outline).

Driving all this is a Java file that runs all these across 4 threads, as per below:

class TestSuiteTest {    
    @Test
    public void testSuiteTest() {
        Results results = Runner.path()
            .tags()
            .outputJunitXml(true)
            .outputCucumberJson(true)
            .relativeTo(getClass())
            .parallel(4);
        assertEquals(0, results.getFailCount(), results.getErrorMessages());
    }  
}

If I run all my tests via the maven command-line, like:

mvn clean test -Dtest=TestSuiteTest

everything works as expected, and the tests run across 4 threads. If, however, I use a tag to trigger a single test (Scenario Outline, driven by a .csv file with 10 rows), via a command like below:

mvn clean test -Dtest=TestSuiteTest -Dkarate.options='--tags @name=one'

it only runs on a single thread.

I've even tried deleting all the other tests, so that I've just one feature file, and it's the same result - not specifying the tag makes it run multi-threaded, specifying the tag runs it single-threaded.

Just wondering if anyone can share some light on this. I expected it to use all 4 threads in all scenarios.

Below is the structure of the test in question, where test_data is set in the config:

Feature: XXX

@setup
Scenario:

@name=one
Scenario Outline: XXX
    * def caseDescription = 'XXX'

    Examples:
    | karate.setup().test_data |

Thanks,

Paul


Solution

  • It is possible you ran into this issue: https://github.com/karatelabs/karate/issues/2444

    There is a workaround in the thread, or you could try 1.5.0.RC3