Search in sources :

Example 6 with EmbedderClassLoader

use of org.jbehave.core.embedder.EmbedderClassLoader in project jbehave-core by jbehave.

the class EmbedderMojoBehaviour method shouldRunStoriesAsPaths.

@Test
public void shouldRunStoriesAsPaths() 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
    mojo.execute();
    // Then
    verify(embedder).runStoriesAsPaths(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 EmbedderClassLoader

use of org.jbehave.core.embedder.EmbedderClassLoader in project jbehave-core by jbehave.

the class EmbedderMojoBehaviour method shouldReportFailuresInRunningStoriesAsEmbeddables.

@Test(expected = MojoFailureException.class)
public void shouldReportFailuresInRunningStoriesAsEmbeddables() 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
    doThrow(new RuntimeException()).when(embedder).runAsEmbeddables(classNames);
    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 8 with EmbedderClassLoader

use of org.jbehave.core.embedder.EmbedderClassLoader 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 9 with EmbedderClassLoader

use of org.jbehave.core.embedder.EmbedderClassLoader 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 10 with EmbedderClassLoader

use of org.jbehave.core.embedder.EmbedderClassLoader 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)

Aggregations

EmbedderClassLoader (org.jbehave.core.embedder.EmbedderClassLoader)17 Matchers.containsString (org.hamcrest.Matchers.containsString)15 StoryFinder (org.jbehave.core.io.StoryFinder)15 Test (org.junit.Test)15 URL (java.net.URL)2 ConfigurableEmbedder (org.jbehave.core.ConfigurableEmbedder)2 InjectableEmbedder (org.jbehave.core.InjectableEmbedder)2 Embedder (org.jbehave.core.embedder.Embedder)2 ExecutorServiceFactory (org.jbehave.core.embedder.executors.ExecutorServiceFactory)2 ArrayList (java.util.ArrayList)1