Have a look at the zip file I just posted under a separate thread.
Might give you a few ideas.  I have managed to get them to run from a
test directory from maven.

Key thing is to put the stories in src/test/resources and then define
stories as testResources to bring them into the test context. 
    <build>
        <testResources>
            <testResource>
                <directory>src/test/resources</directory>
                <filtering>false</filtering>
                <includes>
                    <include>**/*.xml</include>
                    <include>**/*.xsl</include>
                    <include>**/*.xsd</include>
                    <include>**/*.sql</include>
                    <include>**/*.properties</include>
                    <include>**/*.story</include>
                </includes>
            </testResource>
        </testResources>

Then you need to hunt for the stories in your test class runner as
below:
    @Test
    @Override
    public void run() throws Exception {
        List<String> paths = createStoryPaths();
        if( paths == null || paths.isEmpty() ){
            throw new IllegalStateException( "No story paths found for
state machine" );
        }
        LOG.info( "Running [" + this.getClass().getSimpleName() + "]
with stories [" + paths + "]" );
        injectedEmbedder().runStoriesAsPaths( paths );
    }

    private List<String> createStoryPaths() {
        String storyLocation =
CodeLocations.codeLocationFromClass( this.getClass() ).getFile();
        LOG.info( "Running stories from [" + storyLocation + "]" );
        StoryFinder finder = new StoryFinder();
        return finder.findPaths( storyLocation,
                Arrays.asList( "**/*.story" ),
                Arrays.asList( "" ),
                "file:" + storyLocation );
    }


            



On Fri, 2011-03-25 at 16:23 -0500, Edward Staub (JIRA) wrote: 

> Can't run-stories-as-embeddables from test directory using Maven plugin
> -----------------------------------------------------------------------
> 
>                  Key: JBEHAVE-454
>                  URL: http://jira.codehaus.org/browse/JBEHAVE-454
>              Project: JBehave
>           Issue Type: Bug
>           Components: Maven Plugin
>     Affects Versions: 3.1.2
>             Reporter: Edward Staub
> 
> 
> When I tried to use it, the plugin couldn't find my .java file.  
> I suspect that this is because the classloader obtained under Maven with a 
> story that uses 
>           new LoadFromClasspath(this.getClass().getClassLoader())
> as a StoryLoader doesn't include the test class directory - even though the 
> running class is IN the test class directory. The same code works correctly 
> under the Eclipse debugger (including the test class directory in the 
> classpath).  Everything else works correctly in Maven - unit tests, etc.
> The configuration:
> 
>                         <configuration>
>                             
> <sourceDirectory>${project.build.sourceDirectory}</sourceDirectory>
>                             
> <testSourceDirectory>${project.build.testSourceDirectory}</testSourceDirectory>
>                             <includes>
>                                 <include>**/ProcessorTestStory.java</include>
>                             </includes>
>                             <metaFilters>
>                                 <metaFilter>+author *</metaFilter>
>                                 <metaFilter>-skip</metaFilter>
>                             </metaFilters>
>                             <systemProperties>
>                                 <property>
>                                     <name>java.awt.headless</name>
>                                     <value>true</value>
>                                 </property>
>                             </systemProperties>
>                             
> <ignoreFailureInStories>true</ignoreFailureInStories>
>                             <ignoreFailureInView>false</ignoreFailureInView>
>                         </configuration>
> -Ed
> 
> 




Reply via email to