Skip to content

Commit

Permalink
Integrated a better JUnit runner for nicer IDE integration
Browse files Browse the repository at this point in the history
  • Loading branch information
wakaleo committed Jul 18, 2012
1 parent e2b174c commit b3e137b
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 4 deletions.
5 changes: 5 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,10 @@
<artifactId>junit-dep</artifactId>
<version>4.10</version>
</dependency>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>jbehave-junit-runner</artifactId>
<version>1.0.1</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.google.common.base.Splitter;
import com.google.common.collect.Lists;
import de.codecentric.jbehave.junit.monitoring.JUnitReportingRunner;
import net.thucydides.core.ThucydidesSystemProperty;
import net.thucydides.core.guice.Injectors;
import net.thucydides.core.webdriver.ThucydidesWebDriverSupport;
Expand All @@ -10,9 +11,11 @@
import org.jbehave.core.configuration.Configuration;
import org.jbehave.core.embedder.Embedder;
import org.jbehave.core.io.StoryFinder;
import org.jbehave.core.junit.JUnitStories;
import org.jbehave.core.reporters.Format;
import org.jbehave.core.steps.InjectableStepsFactory;
import org.junit.Test;
import org.junit.runner.RunWith;

import java.util.Arrays;
import java.util.List;
Expand All @@ -27,7 +30,8 @@
* By default, it will look for *.story files on the classpath, and steps in or underneath the current package.
* You can redefine these constraints as follows:
*/
public class ThucydidesJUnitStories extends ConfigurableEmbedder {
@RunWith(JUnitReportingRunner.class)
public class ThucydidesJUnitStories extends JUnitStories {// ConfigurableEmbedder {

public static final String DEFAULT_STORY_NAME = "**/*.story";

Expand Down Expand Up @@ -65,7 +69,7 @@ public InjectableStepsFactory stepsFactory() {
return ThucydidesStepFactory.withStepsFromPackage(getRootPackage(), formats);
}

protected List<String> storyPaths() {
public List<String> storyPaths() {
List<String> storyPaths = Lists.newArrayList();

Iterable<String> pathExpressions = getStoryPathExpressions();
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/net/thucydides/jbehave/ThucydidesReporter.java
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,9 @@ private synchronized void generateReports() {
}

public void narrative(Narrative narrative) {
try {
Thread.sleep(1000);
} catch(InterruptedException e) {}
}

public void scenarioNotAllowed(Scenario scenario, String s) {
Expand Down Expand Up @@ -319,7 +322,7 @@ public void notPerformed(String stepTitle) {
public void failed(String stepTitle, Throwable cause) {
StepEventBus.getEventBus().updateCurrentStepTitle(stepTitle);
StepEventBus.getEventBus().stepFailed(new StepFailure(ExecutedStepDescription.withTitle(normalized(stepTitle)), cause));
ThucydidesWebDriverSupport.closeAllDrivers();
//
}

public void failedOutcomes(String s, OutcomesTable outcomesTable) {
Expand Down
4 changes: 4 additions & 0 deletions src/test/java/net/thucydides/jbehave/AllBehaviors.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package net.thucydides.jbehave;

public class AllBehaviors extends ThucydidesJUnitStories {
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ Scenario: Running a simple successful JBehave story

Given a JBehave story
When we run the story with Thucydides
Then it should generate a Thucydides report for this story
Then it should generate a Thucydides report for this story
And it should throw an exception

0 comments on commit b3e137b

Please sign in to comment.