use of org.jbehave.core.io.StoryFinder in project jbehave-core by jbehave.
the class CoreStoryRunner method runClasspathLoadedStoriesAsJUnit.
@Test
public void runClasspathLoadedStoriesAsJUnit() {
// CoreEmbedder defines the configuration and steps factory
Embedder embedder = new CoreEmbedder();
embedder.embedderControls().doIgnoreFailureInStories(true);
List<String> storyPaths = new StoryFinder().findPaths(codeLocationFromClass(this.getClass()), "**/*.story", "");
embedder.runStoriesAsPaths(storyPaths);
}
use of org.jbehave.core.io.StoryFinder in project jbehave-core by jbehave.
the class EmbedderMojoBehaviour method shouldReportFailuresInMappingStoriesAsEmbeddables.
@Test(expected = MojoFailureException.class)
public void shouldReportFailuresInMappingStoriesAsEmbeddables() throws MojoExecutionException, MojoFailureException {
// Given
final EmbedderClassLoader classLoader = new EmbedderClassLoader(this.getClass().getClassLoader());
MapStoriesAsEmbeddables mojo = new MapStoriesAsEmbeddables() {
@Override
protected Embedder newEmbedder() {
return embedder;
}
@Override
protected EmbedderClassLoader classLoader() {
return classLoader;
}
};
String searchInDirectory = "src/test/java/";
mojo.sourceDirectory = searchInDirectory;
List<String> includes = asList("**/*StoryMaps.java");
mojo.includes = includes;
List<String> excludes = asList();
mojo.excludes = excludes;
List<String> classNames = new StoryFinder().findClassNames(searchInDirectory, includes, excludes);
// When
doThrow(new RuntimeException()).when(embedder).runAsEmbeddables(classNames);
mojo.execute();
// Then fail as expected
}
use of org.jbehave.core.io.StoryFinder in project jbehave-core by jbehave.
the class EmbedderMojoBehaviour method shouldRunStoriesAsPaths.
@Test
public void shouldRunStoriesAsPaths() throws MojoExecutionException, MojoFailureException {
// Given
final EmbedderClassLoader classLoader = new EmbedderClassLoader(this.getClass().getClassLoader());
RunStoriesAsPaths mojo = new RunStoriesAsPaths() {
@Override
protected Embedder newEmbedder() {
return embedder;
}
@Override
protected EmbedderClassLoader classLoader() {
return classLoader;
}
};
String searchInDirectory = "src/test/java/";
mojo.sourceDirectory = searchInDirectory;
List<String> includes = asList("**/stories/*.story");
mojo.includes = includes;
List<String> excludes = asList();
mojo.excludes = excludes;
List<String> storyPaths = new StoryFinder().findPaths(searchInDirectory, includes, excludes);
// When
mojo.execute();
// Then
verify(embedder).runStoriesAsPaths(storyPaths);
}
use of org.jbehave.core.io.StoryFinder in project jbehave-core by jbehave.
the class EmbedderMojoBehaviour method shouldReportFailuresInRunningStoriesAsEmbeddables.
@Test(expected = MojoFailureException.class)
public void shouldReportFailuresInRunningStoriesAsEmbeddables() throws MojoExecutionException, MojoFailureException {
// Given
final EmbedderClassLoader classLoader = new EmbedderClassLoader(this.getClass().getClassLoader());
RunStoriesAsEmbeddables mojo = new RunStoriesAsEmbeddables() {
@Override
protected Embedder newEmbedder() {
return embedder;
}
@Override
protected EmbedderClassLoader classLoader() {
return classLoader;
}
};
String searchInDirectory = "src/test/java/";
mojo.sourceDirectory = searchInDirectory;
List<String> includes = asList("**/stories/*.java");
mojo.includes = includes;
List<String> excludes = asList();
mojo.excludes = excludes;
List<String> classNames = new StoryFinder().findClassNames(searchInDirectory, includes, excludes);
// When
doThrow(new RuntimeException()).when(embedder).runAsEmbeddables(classNames);
mojo.execute();
// Then fail as expected
}
use of org.jbehave.core.io.StoryFinder in project jbehave-core by jbehave.
the class EmbedderMojoBehaviour method shouldAllowSpecificationOfStoryFinderClass.
@Test
public void shouldAllowSpecificationOfStoryFinderClass() {
// Given
AbstractEmbedderMojo mojo = new AbstractEmbedderMojo() {
public void execute() throws MojoExecutionException, MojoFailureException {
}
};
// When
mojo.storyFinderClass = MyStoryFinder.class.getName();
StoryFinder storyFinder = mojo.newStoryFinder();
// Then
assertThat(storyFinder.getClass().getName(), equalTo(MyStoryFinder.class.getName()));
}
Aggregations