title: Cucumber+SpringBoot: Retreive application.properties variables and run project via gradle cucumberCli
body: <p>I have been trying to solve this issue whole day, but was not able to do.
  So let describe it:
  My intent:
  In SpringBoot application, in src/resources/application.properties, I have defined two variables:</p>
  <pre><code>myDefaultBrowser=https://www.https://www.mozilla.org/en-US/
  mySecondBrowser=https://www.google.com/chrome/
  </code></pre>
  <p>There is an option to use third variable, but that variable to be obtained from environment.</p>
  <p>What I did:</p>
  <p>Created gradle springboot project. Here is structure:
  <a href="https://i.stack.imgur.com/k2JOm.jpg" rel="nofollow noreferrer">ProjectStructure</a></p>
  <p>I some youtube videos, and googling comes to create structure like that.</p>
  <p>Feature files are: Chrome and Firefox</p>
  <p><strong>Showing firefox.feature</strong></p>
  <pre><code>Feature: Test to see appproperties variable
  
    Scenario: Get and show firefox browser
      When firefox variable is stored into appprop show it
  </code></pre>
  <p><strong>Step definition for firefox:</strong>(similar is for chrome)</p>
  <pre><code>public class FirefoxSD {
  
      @Autowired
      RunConfiguration runConfiguration;
  
      String fireFoxURI;
  
      @Before
      public void setUp() {
          this.fireFoxURI = runConfiguration.getDefaultBrowser();
      }
  
      @When(&quot;firefox variable is stored into appprop show it&quot;)
      public void showFirefoxURI() {
          baseURI = fireFoxURI;
          System.out.println(&quot;***************************************************************&quot;);
          System.out.println(&quot;This is firefox URI from application properties: &quot; + baseURI);
          System.out.println(&quot;***************************************************************&quot;);
      }
  }
  </code></pre>
  <p>Then I created runner class, firefox:</p>
  <pre><code>@RunWith(Cucumber.class)
  @CucumberOptions(
          features = &quot;src/test/resources/featureFiles/firefoxFF&quot;,
          glue ={&quot;com/cucumbertest/cucumber/stepDefinitions/firefoxSD&quot;,&quot;com/cucumbertest/cucumber/cucumberConfig&quot;},
          plugin = { &quot;com.aventstack.extentreports.cucumber.adapter.ExtentCucumberAdapter:&quot;},
          dryRun = false
  )
  
  public class FireFoxRunnerTest {
  }
  </code></pre>
  <p>Crated three more classes:
  <strong>ConfigLoad:</strong></p>
  <pre><code>@Component
  @PropertySource({&quot;classpath:application.properties&quot;})
  public class ConfigLoad {
  }
  </code></pre>
  <p><strong>RunConfigurations:</strong></p>
  <pre><code>@Component
  public class RunConfiguration {
  
      @Value(&quot;${myDefaultBrowser}&quot;)
      private String defaultBrowser;
  
      @Value(&quot;${mySecondBrowser}&quot;)
      private String secondBrowser;
  
      public RunConfiguration() {
      }
  
      public String getDefaultBrowser() {
          return defaultBrowser;
      }
  
      public void setDefaultBrowser(String defaultBrowser) {
          this.defaultBrowser = defaultBrowser;
      }
  
      public String getSecondBrowser() {
          return secondBrowser;
      }
  
      public void setSecondBrowser(String secondBrowser) {
          this.secondBrowser = secondBrowser;
      }
  }
  </code></pre>
  <p><strong>CucumberConfiguration:</strong></p>
  <pre><code>CucumberContextConfiguration
  @SpringBootTest(classes = CucumberApplication.class)
  public class CucumberConfig {
  
  }
  </code></pre>
  <p><strong>build.gradle:</strong></p>
  <pre><code>import org.gradle.api.tasks.testing.logging.TestLogEvent
  
  plugins {
      id 'org.springframework.boot' version '2.6.7'
      id 'io.spring.dependency-management' version '1.0.11.RELEASE'
      id 'java'
  }
  
  group = 'com.cucumbertest'
  version = '0.0.1-SNAPSHOT'
  sourceCompatibility = '17'
  
  repositories {
      mavenCentral()
  }
  
  configurations {
      compileOnly {
          extendsFrom annotationProcessor
      }
  }
  
  dependencies {
      implementation 'org.springframework.boot:spring-boot-starter'
      testImplementation 'org.springframework.boot:spring-boot-starter-test'
  
      testImplementation group: 'org.hamcrest', name: 'hamcrest-all', version: '1.3'
      testImplementation group: 'io.rest-assured', name: 'rest-assured', version: '4.5.1'
      implementation group: 'io.cucumber', name: 'cucumber-java', version: '7.2.3'
      testImplementation group: 'io.cucumber', name: 'cucumber-junit', version: '7.2.3'
      implementation group: 'io.cucumber', name: 'cucumber-spring', version: '7.2.3'
  
  
      testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: '5.8.2'
      testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: '5.8.2'
      testImplementation group: 'org.junit.vintage', name: 'junit-vintage-engine', version: '5.8.2'
  
      implementation group: 'tech.grasshopper', name: 'extentreports-cucumber7-adapter', version: '1.3.0'
      implementation group: 'io.rest-assured', name: 'xml-path', version: '4.5.1'
      implementation group: 'io.rest-assured', name: 'json-path', version: '4.5.1'
  }
  
  // cucumber
  
  configurations {
      cucumberRuntime {
          extendsFrom testImplementation
      }
  }
  
  task cucumberCli() {
      dependsOn assemble, testClasses
      doLast {
          javaexec {
              main = &quot;io.cucumber.core.cli.Main&quot;
              classpath = configurations.cucumberRuntime + sourceSets.main.output + sourceSets.test.output
              args = [
                      '--plugin', 'pretty',
                      '--plugin', 'com.aventstack.extentreports.cucumber.adapter.ExtentCucumberAdapter:',
                      '--glue', 'com/digitalautomationsolution/dascucumber/stepDefinitions',
                      'src/test/resources/featureFiles'
              ]
          }
      }
  }
  
  test {
      useJUnitPlatform()
  
      testLogging {
          events TestLogEvent.FAILED, TestLogEvent.PASSED, TestLogEvent.SKIPPED
      }
  
      systemProperties(project.gradle.startParameter.systemPropertiesArgs)
  }
  </code></pre>
  <p>When I run ChromeRunnerTest and FirefoxRunnerTest, first one then other, test are run just fine, but when I run tests via gradle with: gradle cucumberCli I am receiving this error:</p>
  <pre><code>SEVERE: Exception while executing pickle
  java.util.concurrent.ExecutionException: io.cucumber.core.backend.CucumberBackendException: Please annotate a glue class with some context configuration.
  
  For example:
  
     @CucumberContextConfiguration
     @SpringBootTest(classes = TestConfig.class)
     public class CucumberSpringConfiguration { }
  Or: 
  
     @CucumberContextConfiguration
     @ContextConfiguration( ... )
     public class CucumberSpringConfiguration { }
      at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122)
      at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191)
      at io.cucumber.core.runtime.Runtime.runFeatures(Runtime.java:117)
      at io.cucumber.core.runtime.Runtime.lambda$run$0(Runtime.java:82)
      at io.cucumber.core.runtime.Runtime.execute(Runtime.java:94)
      at io.cucumber.core.runtime.Runtime.run(Runtime.java:80)
      at io.cucumber.core.cli.Main.run(Main.java:87)
      at io.cucumber.core.cli.Main.main(Main.java:30)
  Caused by: io.cucumber.core.backend.CucumberBackendException: Please annotate a glue class with some context configuration.
  </code></pre>
  <p>I have tried to annotate classes with @SpringBootTest (stepDef classes also) but receiving this error.</p>
  <p>Here is code on git: <a href="https://github.com/jovancha/Cucumber" rel="nofollow noreferrer">Github code</a></p>
  <p>What I am doing wrong or what I have missed in my implementation?</p>
  <p>Best regards,
  Jovan.</p>