title: Cucumber Parallel Testing giving weird results
body: <p>I'm trying to run my cucumber project (two runner classes) in parallel browsers and I am getting weird results. When I do a <code>mvn verify</code>,  first it will run each runner class sequentially. The first will pass and the second will fail due to the following error - </p>
  
  <pre><code>org.openqa.selenium.NoSuchSessionException: Session ID is null. Using WebDriver after calling quit()?
  </code></pre>
  
  <p>Then right after, it will run both runner classes in parallel (like I want it to), and all will pass just fine. And maven will report the Build Success.</p>
  
  <p>I am not initializing the webdriver in the <code>@Before</code> annotation. Instead I am using cucumber-picocontainer dependency injection right into my step definition classes. I have tried swapping driver.close() and driver.quit() in my <code>@After</code> annotation, but that didn't change the results. Please find some code snippets below and then my POM. Many thanks in advance.</p>
  
  <pre><code>public class GivenSteps {
  
      WebDriver driver;
      CustomWaits waits;
  
      public GivenSteps(DependencyInjection dependencyInjection) {
          this.driver = dependencyInjection.getDriver();
          this.waits = dependencyInjection.getWaits();
      }
  </code></pre>
  
  <p>Hooks -</p>
  
  <pre><code>    public class Hooks {
  
          WebDriver driver;
  
          public Hooks(DependencyInjection dependencyInjection) {
              this.driver = dependencyInjection.getDriver();
          }
  
          @Before("@setup")
          public void setUp() {
  
              driver.manage().deleteAllCookies();
              driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
              driver.manage().timeouts().pageLoadTimeout(20, TimeUnit.SECONDS);
  
          }
           @After("@destroy")
           public void tearDown() throws Throwable {
            //driver.close();
              driver.quit();
      }
  </code></pre>
  
  <p>Dependency Injection -</p>
  
  <pre><code>public class DependencyInjection {
  
      private static String browserType = Settings.BROWSER.getValue();
      private static WebDriver driver = null;
      private static CustomWaits waits = null;
  
      public WebDriver getDriver() {
          if (driver == null) {
              driver = utilities.DriverFactory.createDriver(browserType);
          }
          return driver;
      }
  </code></pre>
  
  <p>POM.xml -</p>
  
  <pre><code>    &lt;plugin&gt;
                      &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                      &lt;artifactId&gt;maven-surefire-plugin&lt;/artifactId&gt;
                      &lt;version&gt;2.20.1&lt;/version&gt;
                      &lt;configuration&gt;
                          &lt;testFailureIgnore&gt;true&lt;/testFailureIgnore&gt;
                          &lt;includes&gt;
                              &lt;exclude&gt;
                                  **/*Runner.java
                              &lt;/exclude&gt;
                          &lt;/includes&gt;
                      &lt;/configuration&gt;
                  &lt;/plugin&gt;   
                  &lt;plugin&gt;
                      &lt;groupId&gt;com.github.temyers&lt;/groupId&gt;
                      &lt;artifactId&gt;cucumber-jvm-parallel-plugin&lt;/artifactId&gt;
                      &lt;version&gt;5.0.0&lt;/version&gt;
                      &lt;executions&gt;
                          &lt;execution&gt;
                              &lt;id&gt;generateRunners&lt;/id&gt;
                              &lt;phase&gt;generate-test-sources&lt;/phase&gt;
                              &lt;goals&gt;
                                  &lt;goal&gt;generateRunners&lt;/goal&gt;
                              &lt;/goals&gt;
                              &lt;configuration&gt;
                                  &lt;glue&gt;
                                      &lt;package&gt;test.java.stepDefinitions&lt;/package&gt;
                                  &lt;/glue&gt;
                                  &lt;outputDirectory&gt;target/generated-test-sources/cucumber&lt;/outputDirectory&gt;
                                  &lt;featuresDirectory&gt;src/test/resource/&lt;/featuresDirectory&gt;
                                  &lt;cucumberOutputDir&gt;target/Reports/&lt;/cucumberOutputDir&gt;
                                  &lt;namingPattern&gt;Runner{c}&lt;/namingPattern&gt;
                                  &lt;!-- One of [SCENARIO, FEATURE]. SCENARIO generates one runner per 
                                      scenario. FEATURE generates a runner per feature. --&gt;
                                  &lt;parallelScheme&gt;FEATURE&lt;/parallelScheme&gt;
                              &lt;/configuration&gt;
                          &lt;/execution&gt;
                      &lt;/executions&gt;
                  &lt;/plugin&gt;
                  &lt;plugin&gt;
                      &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                      &lt;artifactId&gt;maven-failsafe-plugin&lt;/artifactId&gt;
                      &lt;version&gt;2.19.1&lt;/version&gt;
                      &lt;executions&gt;
                          &lt;execution&gt;
                              &lt;id&gt;acceptance-test&lt;/id&gt;
                              &lt;phase&gt;integration-test&lt;/phase&gt;
                              &lt;goals&gt;
                                  &lt;goal&gt;integration-test&lt;/goal&gt;
                              &lt;/goals&gt;
                              &lt;configuration&gt;
                                  &lt;forkCount&gt;10&lt;/forkCount&gt;
                                  &lt;reuseForks&gt;true&lt;/reuseForks&gt;
                                  &lt;includes&gt;
                                      &lt;include&gt;**/*Runner.class&lt;/include&gt;
                                  &lt;/includes&gt;
                              &lt;/configuration&gt;
                          &lt;/execution&gt;
                      &lt;/executions&gt;
                  &lt;/plugin&gt;
  </code></pre>