Search code examples
junitcucumber-jvmcucumber-javacucumber-junit

Tag feature with browser tests (Cucumber JUnit Platform Engine)


I have several API tests, and browser tests. Browser tests must run consistently. This documentation (https://github.com/cucumber/cucumber-jvm/tree/main/junit-platform-engine) says:

  1. first, I need to run all tests in parallel using the following parameters:
cucumber.execution.parallel.enabled=true
cucumber.execution.parallel.config.strategy=fixed
cucumber.execution.parallel.config.fixed.parallelism=4
  1. then I need mark the resources, access to which will be consistent (read and write, or read only). For example, the resource SYSTEM_PROPERTIES:
cucumber.execution.exclusive-resources.reads-and-writes-system-properties.read-write=SYSTEM_PROPERTIES

But, how can I specify my browser tests instead of this resource?


Solution

  • If your exclusive resource is the browser you mentally reserve the string BROWSER for it. It doesn't really matter what you name the resource, just that it is uniquely identifies the browser.

    Then you decide which Cucumber tag matches this resource, say @browser. Then you remove the @ from the tag and put the remainder in the properties file:

    cucumber.execution.exclusive-resources.browser.read-write=BROWSER
    

    Then you tag your scenario with @browser:

    Feature: Exclusive resources
    
     @browser
     Scenario: first example
       Given this scenario uses the browser
    
     @browser
     Scenario: second example
       Given this scenario uses the browser
    

    You can also tag all scenarios in feature by tagging the feature

    @browser
    Feature: Exclusive resources
    
     Scenario: first example
       Given this scenario uses the browser
    
     Scenario: second example
       Given this scenario uses the browser