title: Getting cucumber.runtime.DuplicateStepDefinitionException despite adding Background in the feature file calc.feature
body: <p>I am getting following error while running my <code>Cucumber</code> <code>Selenium</code> tests using <code>Spring Boot</code></p>
  
  <p>I have already added <code>Background</code> in the feature file. Not sure how to generalize the parameters that are getting passed in it. </p>
  
  <p>Please guide.</p>
  
  <p><strong>Error:</strong></p>
  
  <pre><code>-------------------------------------------------------
   T E S T S
  -------------------------------------------------------
  Running com.example.TestRunner
  Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.388 sec &lt;&lt;&lt; FAILURE! - in com.example.TestRunner
  initializationError(com.example.TestRunner)  Time elapsed: 0.004 sec  &lt;&lt;&lt; ERROR!
  cucumber.runtime.DuplicateStepDefinitionException: Duplicate step definitions in com.example.stepdefs.GoogleCalcStepDefinition.I_enter_in_search_textbox(String) in file:/I:/pet-projects/junit-cucumber-demo/target/test-classes/ and com.example.stepdefs.GoogleCalcSte
  pDefinition.I_enter_in_search_textbox2(String) in file:/I:/pet-projects/junit-cucumber-demo/target/test-classes/
  
  
  Results :
  
  Tests in error:
    TestRunner.initializationError » DuplicateStepDefinition Duplicate step defini...
  
  Tests run: 1, Failures: 0, Errors: 1, Skipped: 0
  
  [ERROR] There are test failures.
  [INFO] About to generate Cucumber report.
  [INFO] ------------------------------------------------------------------------
  [INFO] BUILD FAILURE
  [INFO] ------------------------------------------------------------------------
  [INFO] Total time: 10.281 s
  [INFO] Finished at: 2019-04-12T16:50:23-04:00
  [INFO] ------------------------------------------------------------------------
  </code></pre>
  
  <p><strong>calc.feature</strong></p>
  
  <pre><code>Feature: Check addition in Google calculatorcontent
    In order to verify that Google calculator work correctly
    As a user of Google
    I should be able to get correct addition result
  
    Background: Do some arithmetic on Google
      Given I open Google
  
    Scenario: Addition
      When I enter "2+2" in search textbox
      Then I should get result as "4"
  
    Scenario: Multiplication
      When I enter "5*5" in search textbox
      Then I should get result as "25"
  </code></pre>
  
  <p><strong>GoogleCalcStepDefinition.java</strong></p>
  
  <pre><code>@Ignore
  public class GoogleCalcStepDefinition extends DemoApplicationTests {
  
      WebDriver driver;
      GoogleSearchPage googleSearchPage;
  
      @Given("^I open Google$")
      public void I_open_google() {
          this.driver = BrowserConfig.getWebDriver();
          this.googleSearchPage = PageFactory.initElements(driver, GoogleSearchPage.class);
          driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
          driver.get("https://www.google.com");
      }
  
      @When("^I enter \"([^\"]*)\" in search textbox$")
      public void I_enter_in_search_textbox(String additionTerms) {
          googleSearchPage.searchBox.sendKeys(additionTerms); //passing 2+2 here
          googleSearchPage.searchBtn.click();
      }
  
      @Then("^I should get result as \"([^\"]*)\"$")
      public void I_should_get_correct_result(String expectedResult) {
          String result = googleSearchPage.calculatorTextBox.getText();
          assertEquals(result, expectedResult); //Verify that result of 2+2 is 4
          BrowserConfig.releaseResources(driver);
      }
  
      @When("^I enter \"([^\"]*)\" in search textbox$")
      public void I_enter_in_search_textbox2(String multiplicationTerms) {
          googleSearchPage.searchBox.sendKeys(multiplicationTerms); //passing 5*5 here
          googleSearchPage.searchBtn.click();
      }
  
      @Then("^I should get result as \"([^\"]*)\"$")
      public void I_should_get_correct_result2(String expectedResult) {
          String result = googleSearchPage.calculatorTextBox.getText();
          assertEquals(result, expectedResult); //Verify that result of 5*5 is 25
          BrowserConfig.releaseResources(driver);
      }
  }   
  </code></pre>
  
  <p><strong>DemoApplicationTests.java</strong></p>
  
  <pre><code>@RunWith(SpringRunner.class)
  @SpringBootTest
  public abstract class DemoApplicationTests {
  
  }
  </code></pre>
  
  <p><strong>GoogleSearchPage.java</strong></p>
  
  <p>public class GoogleSearchPage {</p>
  
  <pre><code>    @FindBy(name = "q")
      public WebElement searchBox;
      @FindBy(name = "btnK")
      public WebElement searchBtn;
      @FindBy(id = "cwos")
      public WebElement calculatorTextBox;
  
  }
  </code></pre>
  
  <p><strong>TestRunner.java</strong></p>
  
  <pre><code>@RunWith(Cucumber.class)
  @CucumberOptions(
          plugin = {"pretty", "json:target/cucumber-reports/cucumber.json"},
          glue = {"com.example.stepdefs"},
          features = {"src/test/resources/features"})
  public class TestRunner {
  
  }
  </code></pre>