use of org.jbehave.core.embedder.EmbedderClassLoader in project jbehave-core by jbehave.
the class EmbedderMojoBehaviour method shouldRunStoriesAsEmbeddables.
@Test
public void shouldRunStoriesAsEmbeddables() 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
mojo.execute();
// Then
verify(embedder).runAsEmbeddables(classNames);
}
use of org.jbehave.core.embedder.EmbedderClassLoader in project jbehave-core by jbehave.
the class EmbedderMojoBehaviour method shouldReportFailuresInMappingStoriesAsPaths.
@Test(expected = MojoFailureException.class)
public void shouldReportFailuresInMappingStoriesAsPaths() throws MojoExecutionException, MojoFailureException {
// Given
final EmbedderClassLoader classLoader = new EmbedderClassLoader(this.getClass().getClassLoader());
MapStoriesAsPaths mojo = new MapStoriesAsPaths() {
@Override
protected Embedder newEmbedder() {
return embedder;
}
@Override
protected EmbedderClassLoader classLoader() {
return classLoader;
}
};
String searchInDirectory = "src/test/java/";
mojo.sourceDirectory = searchInDirectory;
mojo.outputDirectory = "target/test-classes";
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
doThrow(new RuntimeException()).when(embedder).mapStoriesAsPaths(storyPaths);
mojo.execute();
// Then fail as expected
}
use of org.jbehave.core.embedder.EmbedderClassLoader in project jbehave-core by jbehave.
the class EmbedderTaskBehaviour method shouldMapStoriesAsPaths.
@Test
public void shouldMapStoriesAsPaths() {
// Given
final EmbedderClassLoader classLoader = new EmbedderClassLoader(this.getClass().getClassLoader());
MapStoriesAsPaths task = new MapStoriesAsPaths() {
@Override
protected Embedder newEmbedder() {
return embedder;
}
@Override
protected EmbedderClassLoader classLoader() {
return classLoader;
}
};
String searchInDirectory = "src/test/java/";
task.setSourceDirectory(searchInDirectory);
List<String> includes = asList("**/stories/*.story");
task.setIncludes(StringUtils.join(includes, "'"));
List<String> excludes = asList();
task.setExcludes(StringUtils.join(excludes, "'"));
List<String> storyPaths = new StoryFinder().findPaths(searchInDirectory, includes, excludes);
// When
task.execute();
// Then
verify(embedder).mapStoriesAsPaths(storyPaths);
}
use of org.jbehave.core.embedder.EmbedderClassLoader in project jbehave-core by jbehave.
the class EmbedderTaskBehaviour method shouldRunStoriesAsEmbeddables.
@Test
public void shouldRunStoriesAsEmbeddables() {
// Given
final EmbedderClassLoader classLoader = new EmbedderClassLoader(this.getClass().getClassLoader());
RunStoriesAsEmbeddables task = new RunStoriesAsEmbeddables() {
@Override
protected Embedder newEmbedder() {
return embedder;
}
@Override
protected EmbedderClassLoader classLoader() {
return classLoader;
}
};
String searchInDirectory = "src/test/java/";
task.setSourceDirectory(searchInDirectory);
List<String> includes = asList("**/stories/*.java");
task.setIncludes(StringUtils.join(includes, "'"));
List<String> excludes = asList();
task.setExcludes(StringUtils.join(excludes, "'"));
List<String> classNames = new StoryFinder().findClassNames(searchInDirectory, includes, excludes);
// When
task.execute();
// Then
verify(embedder).runAsEmbeddables(classNames);
}
use of org.jbehave.core.embedder.EmbedderClassLoader 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
}
Aggregations