Search in sources :

Example 16 with EmbedderClassLoader

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

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

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