Skip to content

Commit

Permalink
Updated to core 1.2.3, and refactored the logic that closes the brows…
Browse files Browse the repository at this point in the history
…ers at the end of a story
  • Loading branch information
wakaleo committed Aug 2, 2015
1 parent c247784 commit 4d33134
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ ext {
if (!project.hasProperty("bintrayApiKey")) {
bintrayApiKey = ''
}
serenityCoreVersion = '1.1.1'
serenityCoreVersion = '1.1.3'

if (!project.hasProperty("bintrayApiKey")) {
bintrayApiKey = ''
Expand Down Expand Up @@ -123,6 +123,7 @@ dependencies {
}
compile('com.googlecode.lambdaj:lambdaj:2.3.3') {
exclude group: 'org.objenesis', module: 'objenesis'
exclude group: 'org.hamcrest', module: 'hamcrest-all'
}
compile("org.codehaus.groovy:groovy-all:2.3.3")
compile "junit:junit:4.11"
Expand Down
12 changes: 10 additions & 2 deletions src/main/java/net/serenitybdd/jbehave/SerenityReporter.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import org.jbehave.core.model.StoryDuration;
import org.jbehave.core.reporters.StoryReporter;
import org.junit.internal.AssumptionViolatedException;
import org.openqa.selenium.WebDriver;

import java.io.File;
import java.util.List;
Expand Down Expand Up @@ -244,11 +245,14 @@ private boolean hasSameName(Story story, String givenStoryName) {
return story.getName().equalsIgnoreCase(givenStoryName);
}

Map<Story, WebDriver> drivers = Maps.newConcurrentMap();

private void configureDriver(Story story) {
StepEventBus.getEventBus().setUniqueSession(systemConfiguration.getUseUniqueBrowser());
String requestedDriver = getRequestedDriver(story.getMeta());
if (StringUtils.isNotEmpty(requestedDriver)) {
ThucydidesWebDriverSupport.initialize(requestedDriver);
drivers.put(story, ThucydidesWebDriverSupport.getDriver());
} else {
ThucydidesWebDriverSupport.initialize();
}
Expand Down Expand Up @@ -449,8 +453,8 @@ public void afterStory(boolean given) {
givenStoryMonitor.exitingGivenStory();
givenStoryDone(currentStory());
} else {
closeBrowsersForThisStory();
if (isAfterStory(currentStory())) {
closeBrowsersForThisStory();
generateReports();
} else if (!isFixture(currentStory()) && !given && (!isAStoryLevelGiven(currentStory()))) {
StepEventBus.getEventBus().testSuiteFinished();
Expand All @@ -461,7 +465,11 @@ public void afterStory(boolean given) {
}

private void closeBrowsersForThisStory() {
ThucydidesWebDriverSupport.closeAllDrivers();
if (drivers.containsKey(currentStory())) {
drivers.get(currentStory()).close();
drivers.get(currentStory()).quit();
drivers.remove(currentStory());
}
}

private boolean isAfterStory(Story currentStory) {
Expand Down

0 comments on commit 4d33134

Please sign in to comment.