Search in sources :

Example 6 with StoryFinder

use of org.jbehave.core.io.StoryFinder 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);
}
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 7 with StoryFinder

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

the class EmbedderTaskBehaviour method shouldAllowSpecificationOfStoryFinderClass.

@Test
public void shouldAllowSpecificationOfStoryFinderClass() {
    // Given
    AbstractEmbedderTask task = new AbstractEmbedderTask() {
    };
    // When
    task.setStoryFinderClass(MyStoryFinder.class.getName());
    StoryFinder storyFinder = task.newStoryFinder();
    // Then
    assertThat(storyFinder.getClass().getName(), equalTo(MyStoryFinder.class.getName()));
}
Also used : StoryFinder(org.jbehave.core.io.StoryFinder) Test(org.junit.Test)

Example 8 with StoryFinder

use of org.jbehave.core.io.StoryFinder 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);
}
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 9 with StoryFinder

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

the class IndexWithBreadcrumbs method createIndexFromPaths.

protected Map<String, Resource> createIndexFromPaths(String rootURI, String rootPath, String syntax, String includes) {
    Map<String, Resource> index = new HashMap<>();
    List<String> paths = new StoryFinder().findPaths(codeLocationFromPath(rootPath), includes, EMPTY);
    for (String path : paths) {
        addPath(rootURI, rootPath, fullPath(rootPath, path), syntax, index);
    }
    return index;
}
Also used : StoryFinder(org.jbehave.core.io.StoryFinder) HashMap(java.util.HashMap)

Example 10 with StoryFinder

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

the class CoreStoryRunner method mapStories.

@Test
public void mapStories() {
    Embedder embedder = new Embedder();
    embedder.useMetaFilters(asList("+author *", "+theme *", "-skip"));
    List<String> storyPaths = new StoryFinder().findPaths(codeLocationFromClass(this.getClass()), "**/*.story", "");
    embedder.mapStoriesAsPaths(storyPaths);
}
Also used : StoryFinder(org.jbehave.core.io.StoryFinder) Embedder(org.jbehave.core.embedder.Embedder) 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