Search in sources :

Example 1 with StoryFinder

use of org.jbehave.core.io.StoryFinder in project serenity-jbehave by serenity-bdd.

the class SerenityStories method storyPaths.

public List<String> storyPaths() {
    Set<String> storyPaths = new HashSet<>();
    List<String> pathExpressions = getStoryPathExpressions();
    StoryFinder storyFinder = new StoryFinder();
    for (String pathExpression : pathExpressions) {
        if (absolutePath(pathExpression)) {
            storyPaths.add(pathExpression);
        }
        for (URL classpathRootUrl : allClasspathRoots()) {
            storyPaths.addAll(storyFinder.findPaths(classpathRootUrl, pathExpression, ""));
        }
        storyPaths = removeDuplicatesFrom(storyPaths);
        storyPaths = pruneGivenStoriesFrom(storyPaths);
    }
    return sorted(storyPaths);
}
Also used : StoryFinder(org.jbehave.core.io.StoryFinder) URL(java.net.URL) HashSet(java.util.HashSet)

Example 2 with StoryFinder

use of org.jbehave.core.io.StoryFinder in project jbehave-core by jbehave.

the class CoreAnnotatedEmbedder method run.

@Test
public void run() {
    List<String> storyPaths = new StoryFinder().findPaths(codeLocationFromPath("../core/src/main/java"), "**/*.story", "**/examples_table_loaded*");
    injectedEmbedder().runStoriesAsPaths(storyPaths);
}
Also used : StoryFinder(org.jbehave.core.io.StoryFinder) Test(org.junit.Test)

Example 3 with StoryFinder

use of org.jbehave.core.io.StoryFinder 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);
}
Also used : StoryFinder(org.jbehave.core.io.StoryFinder) EmbedderClassLoader(org.jbehave.core.embedder.EmbedderClassLoader) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Example 4 with StoryFinder

use of org.jbehave.core.io.StoryFinder 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
}
Also used : StoryFinder(org.jbehave.core.io.StoryFinder) EmbedderClassLoader(org.jbehave.core.embedder.EmbedderClassLoader) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Example 5 with StoryFinder

use of org.jbehave.core.io.StoryFinder in project jbehave-core by jbehave.

the class CoreEmbedderWithSpringJUnit4ClassRunner method runStoriesAsPaths.

@Test
public void runStoriesAsPaths() {
    List<String> storyPaths = new StoryFinder().findPaths(codeLocationFromPath("../core/src/main/java"), "**/*.story", "");
    embedder.runStoriesAsPaths(storyPaths);
}
Also used : StoryFinder(org.jbehave.core.io.StoryFinder) Test(org.junit.Test)

Aggregations

StoryFinder (org.jbehave.core.io.StoryFinder)24 Test (org.junit.Test)22 Matchers.containsString (org.hamcrest.Matchers.containsString)15 EmbedderClassLoader (org.jbehave.core.embedder.EmbedderClassLoader)15 Embedder (org.jbehave.core.embedder.Embedder)3 URL (java.net.URL)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1