Skip to content

Commit

Permalink
Fixed a bug that incorrectly reported a failing test if another test …
Browse files Browse the repository at this point in the history
…had previously failed
  • Loading branch information
wakaleo committed Jul 10, 2012
1 parent 2718e0a commit 28261da
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 7 deletions.
5 changes: 5 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,10 @@
<version>0.3b</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit-dep</artifactId>
<version>4.10</version>
</dependency>
</dependencies>
</project>
20 changes: 15 additions & 5 deletions src/main/java/net/thucydides/jbehave/ThucydidesJUnitStories.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

import com.google.common.base.Splitter;
import com.google.common.collect.Lists;
import net.thucydides.core.ThucydidesSystemProperties;
import net.thucydides.core.ThucydidesSystemProperty;
import net.thucydides.core.guice.Injectors;
import net.thucydides.core.webdriver.ThucydidesWebDriverSupport;
import org.apache.log4j.net.SMTPAppender;
import org.codehaus.plexus.util.StringUtils;
import org.jbehave.core.ConfigurableEmbedder;
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 java.util.Arrays;
import java.util.List;
Expand All @@ -27,7 +27,7 @@
* 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 abstract class ThucydidesJUnitStories extends JUnitStories {
public class ThucydidesJUnitStories extends ConfigurableEmbedder {

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

Expand All @@ -39,6 +39,17 @@ public abstract class ThucydidesJUnitStories extends JUnitStories {
private Configuration configuration;
private List<Format> formats = Arrays.asList(CONSOLE, HTML, XML);

@Test
public void run() throws Throwable {
Embedder embedder = configuredEmbedder();
embedder.embedderControls().doIgnoreFailureInView(true);
try {
embedder.runStoriesAsPaths(storyPaths());
} finally {
embedder.generateCrossReference();
}
}

@Override
public Configuration configuration() {
if (configuration == null) {
Expand All @@ -52,7 +63,6 @@ public InjectableStepsFactory stepsFactory() {
return ThucydidesStepFactory.withStepsFromPackage(getRootPackage(), formats);
}

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

Expand Down
10 changes: 8 additions & 2 deletions src/main/java/net/thucydides/jbehave/ThucydidesJUnitStory.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package net.thucydides.jbehave;

import net.thucydides.core.util.Inflector;
import org.codehaus.plexus.util.StringUtils;
import org.jbehave.core.embedder.Embedder;

/**
* Run an individual JBehave story in JUnit, where the name of the story is derived from the name of the test.
Expand All @@ -13,17 +15,21 @@ public ThucydidesJUnitStory() {

@Override
public void run() throws Throwable {
super.run(); //To change body of overridden methods use File | Settings | File Templates.
super.run();
}

protected String storynamesDerivedFromClassName() {
return camelCaseStoryName() + ";" + underscoreStoryName();
return camelCaseStoryName() + ";" + underscoreStoryName() + ";" + camelCaseStartingWithLowercaseStoryName();
}

private String camelCaseStoryName() {
return "**/" + simpleClassName() + ".story";
}

private String camelCaseStartingWithLowercaseStoryName() {
return "**/" + StringUtils.uncapitalise(simpleClassName()) + ".story";
}

private String simpleClassName() {
return this.getClass().getSimpleName();
}
Expand Down
4 changes: 4 additions & 0 deletions src/test/java/net/thucydides/jbehave/AFailingBehavior.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package net.thucydides.jbehave;

public class AFailingBehavior extends ThucydidesJUnitStory {
}

0 comments on commit 28261da

Please sign in to comment.