title: TestNG + Cucumber JVM parallel execution
body: <p>I'm tryting to run our Cucumber JVM tests by few threads in parallel.
  I'm using standart TastNG approach to do it (via suite XML file)
  My xml file is:</p>
  
  <pre><code>&lt;!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" &gt;
  &lt;suite name="BDD" parallel="methods" thread-count="3" data-provider-thread-count="3"&gt;
      &lt;test name="BDD"&gt;
          &lt;classes&gt;
              &lt;class name="com.tests.bdd.SimpleBDDTests"&gt;&lt;/class&gt;
          &lt;/classes&gt;
      &lt;/test&gt;
  &lt;/suite&gt;
  </code></pre>
  
  <p>My test class is:</p>
  
  <pre><code>@CucumberOptions(features = "src/test/java/com/tests/bdd/simpleFeatures")
  public class SimpleBDDTests {
  private TestNGCucumberRunner tcr;
  @BeforeClass(alwaysRun = true)
  public void beforeClass() throws Exception {
      tcr = new TestNGCucumberRunner(this.getClass());
  }
  
  @AfterClass(alwaysRun = true)
  public void afterClass() {
      tcr.finish();
  }
  
  @Test(dataProvider = "features")
  public void feature(CucumberFeatureWrapper cucumberFeature) {
      tcr.runCucumber(cucumberFeature.getCucumberFeature());
  }
  
  @DataProvider(parallel = true)
  public Object[][] features() {
      return tcr.provideFeatures();
  }}
  </code></pre>
  
  <p>My feature files are like:</p>
  
  <pre><code>Feature: First test
  
    @sanity
    Scenario: First simple test
      Given Base check step
  </code></pre>
  
  <p>I have 4 feature files, which are defines the same scenarios with only one step - Given Base check step</p>
  
  <p>When these features are executed one by one, it works fine, but when i try to run them in parallel, everything gets broken.
  Almost all of these featres marked as failed with the following exception:</p>
  
  <pre><code>A scoping block is already in progress
  java.lang.IllegalStateException: A scoping block is already in progress
      at cucumber.runtime.java.guice.impl.SequentialScenarioScope.checkState(SequentialScenarioScope.java:64)
      at cucumber.runtime.java.guice.impl.SequentialScenarioScope.enterScope(SequentialScenarioScope.java:52)
      at cucumber.runtime.java.guice.impl.GuiceFactory.start(GuiceFactory.java:34)
      at cucumber.runtime.java.JavaBackend.buildWorld(JavaBackend.java:123)
      at cucumber.runtime.Runtime.buildBackendWorlds(Runtime.java:141)
      at cucumber.runtime.model.CucumberScenario.run(CucumberScenario.java:38)
      at cucumber.runtime.model.CucumberFeature.run(CucumberFeature.java:165)
      at cucumber.api.testng.TestNGCucumberRunner.runCucumber(TestNGCucumberRunner.java:63)
  </code></pre>
  
  <p>I understand that it might be happen because of multi-thread calls to the same step - Given Base check step</p>
  
  <p>So my question is how can i fix that? How can i run these tests in parallel?</p>
  
  <p>PS: I know that it should be possible to do it by JUnit + Maven surefire plugin, but it is not applicable for current project, we need to achieve that goal by TestNG.</p>
  
  <p>Thanks.</p>