title: Cucumber BDD different features requiring similar step
body: <p>In my application I have two feature files:</p>
  <pre><code>processing.feature
  copy.feature
  </code></pre>
  <p>For these I have two step definition files:</p>
  <p>Processing Feature:</p>
  <pre><code>public class ProcessingFeature {
  
      @Qualifier(&quot;moverA&quot;)
      @Autowired
      private IFileMover mover;
  
  
      @Given(&quot;check file is available&quot;)
      public void load() {
  
      }
  
      @When(&quot;the file is there at the location&quot;)
      public void moveFile() {
          output= mover.move(info);
  
      }   
  }
  </code></pre>
  <p>Copy Feature:</p>
  <pre><code>public class CopyFeature {
  
      @Qualifier(&quot;moverB&quot;)
      @Autowired
      private IFileMover mover;
  
  
      @Given(&quot;check file is available&quot;)
      public void load() {
  
      }
  
      @When(&quot;the file is there at the location&quot;)
      public void moveFile() {
          output= mover.move(info);
  
      }   
  }
  </code></pre>
  <p>In both my feature files, I run <code>check file is available</code> as <code>@Given</code> step. My first question is, they are identical step definitions sitting in both step def file. What is the correct pattern so this code is not duplicated and both features can make use of it?</p>
  <p>Secondly, both features run <code>the file is there at the location</code> but one uses <code>MoverA</code> &amp; the Other uses <code>MoverB</code>. But the idea remains same. Again I don't like the duplication so how best can I re-use maybe through some abstraction ?</p>
  <p>Ofcourse I get <code>cucumber.runtime.DuplicateStepDefinitionException: Duplicate step definitions</code> exception but I am curious to see what is correct pattern to solve these kind of problems</p>