Search in sources :

Example 21 with StoryFinder

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

the class EmbedderTaskBehaviour method shouldMapStoriesAsEmbeddables.

@Test
public void shouldMapStoriesAsEmbeddables() {
    // Given
    final EmbedderClassLoader classLoader = new EmbedderClassLoader(this.getClass().getClassLoader());
    MapStoriesAsEmbeddables task = new MapStoriesAsEmbeddables() {

        @Override
        protected Embedder newEmbedder() {
            return embedder;
        }

        @Override
        protected EmbedderClassLoader classLoader() {
            return classLoader;
        }
    };
    String searchInDirectory = "src/test/java/";
    task.setSourceDirectory(searchInDirectory);
    task.setOutputDirectory("target/test-classes");
    List<String> includes = asList("**/*StoryMaps.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 22 with StoryFinder

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

the class EmbedderTaskBehaviour method shouldRunStoriesAsPaths.

@Test
public void shouldRunStoriesAsPaths() {
    // Given
    final EmbedderClassLoader classLoader = new EmbedderClassLoader(this.getClass().getClassLoader());
    RunStoriesAsPaths task = new RunStoriesAsPaths() {

        @Override
        protected Embedder newEmbedder() {
            return embedder;
        }

        @Override
        protected EmbedderClassLoader classLoader() {
            return classLoader;
        }
    };
    String searchInDirectory = "src/test/java/";
    task.setSourceDirectory(searchInDirectory);
    String outputDirectory = "target/test-classes";
    task.setOutputDirectory(outputDirectory);
    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).runStoriesAsPaths(storyPaths);
    assertThat(task.codeLocation().toString(), containsString(outputDirectory));
}
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 23 with StoryFinder

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

the class EmbedderTaskBehaviour method shouldRunStoriesWithAnnotatedEmbedderRunner.

@Test
public void shouldRunStoriesWithAnnotatedEmbedderRunner() {
    // Given
    final EmbedderClassLoader classLoader = new EmbedderClassLoader(this.getClass().getClassLoader());
    RunStoriesWithAnnotatedEmbedderRunner task = new RunStoriesWithAnnotatedEmbedderRunner() {

        @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).runStoriesWithAnnotatedEmbedderRunner(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 24 with StoryFinder

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

the class CoreStoryRunner method runURLLoadedStoriesAsJUnit.

@Test
public void runURLLoadedStoriesAsJUnit() {
    // Embedder defines the configuration and candidate steps
    Embedder embedder = new URLCoreEmbedder();
    String codeLocation = codeLocationFromClass(this.getClass()).getFile();
    List<String> storyPaths = new StoryFinder().findPaths(codeLocation, asList("**/trader_is_alerted_of_status.story", "**/traders_can_be_searched.story"), null, "file:" + codeLocation);
    embedder.runStoriesAsPaths(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