Search in sources :

Example 16 with StoryFinder

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

the class EmbedderMojoBehaviour method shouldRunStoriesWithAnnotatedEmbedderRunner.

@Test
public void shouldRunStoriesWithAnnotatedEmbedderRunner() throws MojoExecutionException, MojoFailureException {
    // Given
    final EmbedderClassLoader classLoader = new EmbedderClassLoader(this.getClass().getClassLoader());
    RunStoriesWithAnnotatedEmbedderRunner mojo = new RunStoriesWithAnnotatedEmbedderRunner() {

        @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).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 17 with StoryFinder

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

the class EmbedderMojoBehaviour method shouldMapStoriesAsEmbeddables.

@Test
public void shouldMapStoriesAsEmbeddables() 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
    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 18 with StoryFinder

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

the class EmbedderMojoBehaviour method shouldMapStoriesAsPaths.

@Test
public void shouldMapStoriesAsPaths() 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
    mojo.execute();
    // Then
    verify(embedder).mapStoriesAsPaths(storyPaths);
    assertThat(mojo.codeLocation().toString(), containsString(mojo.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 19 with StoryFinder

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

the class EmbedderMojoBehaviour method shouldReportFailuresInRunningStoriesWithAnnotatedEmbedderRunner.

@Test(expected = MojoFailureException.class)
public void shouldReportFailuresInRunningStoriesWithAnnotatedEmbedderRunner() throws MojoExecutionException, MojoFailureException {
    // Given
    final EmbedderClassLoader classLoader = new EmbedderClassLoader(this.getClass().getClassLoader());
    RunStoriesWithAnnotatedEmbedderRunner mojo = new RunStoriesWithAnnotatedEmbedderRunner() {

        @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).runStoriesWithAnnotatedEmbedderRunner(classNames);
    mojo.execute();
    // Then fail as expected
    mojo.execute();
}
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 20 with StoryFinder

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

the class EmbedderMojoBehaviour method shouldReportFailuresInRunningStoriesAsPaths.

@Test(expected = MojoFailureException.class)
public void shouldReportFailuresInRunningStoriesAsPaths() 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
    doThrow(new RuntimeException()).when(embedder).runStoriesAsPaths(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)

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