Details
-
Type: Bug
-
Status: Open
-
Priority: Major
-
Resolution: Unresolved
-
Affects Version/s: 3.1.2
-
Fix Version/s: None
-
Component/s: Maven Plugin
-
Labels:None
-
Number of attachments :0
Description
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>$
</sourceDirectory>
<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
1. |
Jbehave Maven Integration Exceptions | Resolved | Unassigned |
Activity
Sorry.
Do you know that it works when configured correctly (however that is)?
Try this, it fails on my rig at least:
In the jbehave distribution directory
examples/gameoflife
{{
# WORKS FINE mvn integration-test mvn clean # move the stories to the test directory mv src\main\java\com\lunivore\gameoflife\stories src\test\java\com\lunivore\gameoflife # FAILS mvn integration-test
}}
---------
Here's the relevant part of the console output. Note the classpath "urls=" on the third line, which doesn't include the test directory, and the final line, where it shows all the stories it found (none).
{{
[INFO] Running stories using embedder Embedder[configuration=org.jbehave.core.configuration.MostUsefulConfiguration@bc9673, candidateSteps=[],classLoader=EmbedderClassLoader[ urls=[/C:/v/jbehave/jbehave-distribution-3.2-src/jbehave-3.2/examples/gameoflife/target/classes/, jbehave-core-3.2-SNAPSHOT.jar, commons-collections-3.2.1.jar, commons-io-1.4.jar, commons-lang-2.5.jar, plexus-utils-2.0.5.jar, freemarker-2.3.16.jar, jbehave-ant-3.2-SNAPSHOT.jar, ant-1.7.1.jar, ant-launcher-1.7.1.jar, xstream-1.3.1.jar, xpp3_min-1.1.4c.jar, junit-dep-4.8.2.jar, hamcrest-all-1.1.jar],parent=ClassRealm[plugin>org.jbehave:jbehave-maven-plugin:3.2-SNAPSHOT, parent: sun.misc.Launcher$AppClassLoader@11b86e7]],embedderControls=UnmodifiableEmbedderControls[EmbedderControls[batch=false,skip=false,generateViewAfterStories=true,ignoreFailureInStories=true,ignoreFailureInView=true]],metaFilters=[null],systemProperties=},storyMapper=StoryMapper,storyRunner=StoryRunner,embedderMonitor=MavenEmbedderMonitor] [INFO] Found class names: []
}}
-Ed
Edward,
Don't take me bad, but it is always a good practice to send an email to the user list before open issues like this, mostly without a good reproducible example. Always will be someone to help you there.
You should think that people that is 'given' this amazing tool to the community (as Mauro and Paul) is not receiving nothing for this and they have to work to pay bills too. ok?
So, for your example you just don't put the <scope>test</scope> in your POM, as stated here: http://jbehave.org/reference/latest/maven-goals.html
<execution> <id>run-stories</id> <phase>integration-test</phase> <configuration> -<scope>test</scope>- <includes> <include>**/stories/*.java</include> </includes> </configuration> <goals> <goal>run-stories-as-embeddables</goal> </goals> </execution>
I did what you suggested. See the result:
Mob4biz:gameoflife cvgaviao$ mvn integration-test [INFO] Scanning for projects... [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building JBehave Game of Life Example 3.3-SNAPSHOT [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-resources-plugin:2.4:resources (default-resources) @ jbehave-gameoflife-example --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] Copying 0 resource [INFO] [INFO] --- jbehave-maven-plugin:3.3-SNAPSHOT:unpack-view-resources (unpack-view-resources) @ jbehave-gameoflife-example --- [INFO] Unpacked /Users/cvgaviao/.m2/repository/org/jbehave/site/jbehave-site-resources/3.1.1/jbehave-site-resources-3.1.1.zip to /Users/cvgaviao/Development/Development_Projects/jbehave-fork/jbehave-core/examples/gameoflife/target/jbehave/view [INFO] Unpacked /Users/cvgaviao/.m2/repository/org/jbehave/jbehave-core/3.3-SNAPSHOT/jbehave-core-3.3-SNAPSHOT-resources.zip to /Users/cvgaviao/Development/Development_Projects/jbehave-fork/jbehave-core/examples/gameoflife/target/jbehave/view [INFO] [INFO] --- maven-compiler-plugin:2.1:compile (default-compile) @ jbehave-gameoflife-example --- [INFO] Nothing to compile - all classes are up to date [INFO] [INFO] --- maven-resources-plugin:2.4:testResources (default-testResources) @ jbehave-gameoflife-example --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] skip non existing resourceDirectory /Users/cvgaviao/Development/Development_Projects/jbehave-fork/jbehave-core/examples/gameoflife/src/test/resources [INFO] Copying 3 resources [INFO] [INFO] --- maven-compiler-plugin:2.1:testCompile (default-testCompile) @ jbehave-gameoflife-example --- [INFO] Nothing to compile - all classes are up to date [INFO] [INFO] --- maven-surefire-plugin:2.5:test (default-test) @ jbehave-gameoflife-example --- [INFO] Surefire report directory: /Users/cvgaviao/Development/Development_Projects/jbehave-fork/jbehave-core/examples/gameoflife/target/surefire-reports ------------------------------------------------------- T E S T S ------------------------------------------------------- Running com.lunivore.gameoflife.domain.CellBehaviour Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.095 sec Running com.lunivore.gameoflife.view.string.StringRendererBehaviour Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.21 sec Running com.lunivore.gameoflife.domain.GameBehaviour Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.009 sec Results : Tests run: 4, Failures: 0, Errors: 0, Skipped: 0 [INFO] [INFO] --- maven-jar-plugin:2.3.1:jar (default-jar) @ jbehave-gameoflife-example --- [INFO] [INFO] --- jbehave-maven-plugin:3.3-SNAPSHOT:run-stories-as-embeddables (embeddable-stories) @ jbehave-gameoflife-example --- [INFO] Running stories using embedder Embedder[configuration=org.jbehave.core.configuration.MostUsefulConfiguration@552297d7,candidateSteps=[],classLoader=EmbedderClassLoader[urls=[/Users/cvgaviao/Development/Development_Projects/jbehave-fork/jbehave-core/examples/gameoflife/target/classes/, jbehave-core-3.3-SNAPSHOT.jar, commons-collections-3.2.1.jar, commons-io-1.4.jar, commons-lang-2.5.jar, plexus-utils-2.0.5.jar, freemarker-2.3.16.jar, paranamer-2.3.jar, jbehave-ant-3.3-SNAPSHOT.jar, ant-1.7.1.jar, ant-launcher-1.7.1.jar, xstream-1.3.1.jar, xpp3_min-1.1.4c.jar, junit-dep-4.8.2.jar, hamcrest-all-1.1.jar, maven-default-skin-1.0.jar],parent=ClassRealm[plugin>org.jbehave:jbehave-maven-plugin:3.3-SNAPSHOT, parent: sun.misc.Launcher$AppClassLoader@535ff48b]],embedderControls=UnmodifiableEmbedderControls[EmbedderControls[batch=false,skip=false,generateViewAfterStories=true,ignoreFailureInStories=true,ignoreFailureInView=true,threads=2]],metaFilters=[null],systemProperties={},storyMapper=StoryMapper,storyRunner=StoryRunner,embedderMonitor=MavenEmbedderMonitor,executorService=org.jbehave.core.embedder.Embedder$NonThreadingExecutorService@a9db0e2] [INFO] Found class names: [] [INFO] [INFO] --- jbehave-maven-plugin:3.3-SNAPSHOT:run-stories-as-embeddables (run-stories) @ jbehave-gameoflife-example --- [INFO] Running stories using embedder Embedder[configuration=org.jbehave.core.configuration.MostUsefulConfiguration@7371b4ca,candidateSteps=[],classLoader=EmbedderClassLoader[urls=[/Users/cvgaviao/Development/Development_Projects/jbehave-fork/jbehave-core/examples/gameoflife/target/test-classes/, /Users/cvgaviao/Development/Development_Projects/jbehave-fork/jbehave-core/examples/gameoflife/target/classes/, jbehave-core-3.3-SNAPSHOT.jar, commons-collections-3.2.1.jar, commons-io-1.4.jar, commons-lang-2.5.jar, plexus-utils-2.0.5.jar, freemarker-2.3.16.jar, paranamer-2.3.jar, jbehave-ant-3.3-SNAPSHOT.jar, ant-1.7.1.jar, ant-launcher-1.7.1.jar, xstream-1.3.1.jar, xpp3_min-1.1.4c.jar, junit-dep-4.8.2.jar, hamcrest-all-1.1.jar, maven-default-skin-1.0.jar],parent=ClassRealm[plugin>org.jbehave:jbehave-maven-plugin:3.3-SNAPSHOT, parent: sun.misc.Launcher$AppClassLoader@535ff48b]],embedderControls=UnmodifiableEmbedderControls[EmbedderControls[batch=false,skip=false,generateViewAfterStories=true,ignoreFailureInStories=false,ignoreFailureInView=false,threads=1]],metaFilters=[],systemProperties={},storyMapper=StoryMapper,storyRunner=StoryRunner,embedderMonitor=MavenEmbedderMonitor,executorService=org.jbehave.core.embedder.Embedder$NonThreadingExecutorService@72cc5002] [INFO] Found class names: [com.lunivore.gameoflife.stories.ICanToggleACell, com.lunivore.gameoflife.stories.TheGridStartsEmpty] [INFO] Running embeddable com.lunivore.gameoflife.stories.ICanToggleACell [INFO] Processing system properties {} [INFO] Running story com/lunivore/gameoflife/stories/i_can_toggle_a_cell.story (com/lunivore/gameoflife/stories/i_can_toggle_a_cell.story) Scenario: Given a 5 by 5 game When I toggle the cell at (2, 3) Then the grid should look like ..... ..... ..... ..X.. ..... When I toggle the cell at (2, 4) Then the grid should look like ..... ..... ..... ..X.. ..X.. When I toggle the cell at (2, 3) Then the grid should look like ..... ..... ..... ..... ..X.. [INFO] Generating reports view to '/Users/cvgaviao/Development/Development_Projects/jbehave-fork/jbehave-core/examples/gameoflife/target/jbehave' using formats '[stats, console, txt]' and view properties '{defaultFormats=stats, decorateNonHtml=true, viewDirectory=view, decorated=ftl/jbehave-report-decorated.ftl, reports=ftl/jbehave-reports-with-totals.ftl, maps=ftl/jbehave-maps.ftl, navigator=ftl/jbehave-navigator.ftl, views=ftl/jbehave-views.ftl, nonDecorated=ftl/jbehave-report-non-decorated.ftl}' [INFO] Reports view generated with 1 stories containing 1 scenarios (of which 0 failed) [INFO] Running embeddable com.lunivore.gameoflife.stories.TheGridStartsEmpty [INFO] Processing system properties {} [INFO] Running story com/lunivore/gameoflife/stories/the_grid_starts_empty.story (com/lunivore/gameoflife/stories/the_grid_starts_empty.story) Scenario: Given a new game: 5 by 5 Then the grid should be ..... ..... ..... ..... ..... [INFO] Generating reports view to '/Users/cvgaviao/Development/Development_Projects/jbehave-fork/jbehave-core/examples/gameoflife/target/jbehave' using formats '[stats, console, txt]' and view properties '{defaultFormats=stats, decorateNonHtml=true, viewDirectory=view, decorated=ftl/jbehave-report-decorated.ftl, reports=ftl/jbehave-reports-with-totals.ftl, maps=ftl/jbehave-maps.ftl, navigator=ftl/jbehave-navigator.ftl, views=ftl/jbehave-views.ftl, nonDecorated=ftl/jbehave-report-non-decorated.ftl}' [INFO] Reports view generated with 2 stories containing 2 scenarios (of which 0 failed) [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 4.384s [INFO] Finished at: Fri Mar 25 23:34:22 BRT 2011 [INFO] Final Memory: 6M/265M [INFO] ------------------------------------------------------------------------
regards
The noughtsandcrosses example (https://github.com/jbehave/jbehave-core/tree/master/examples/noughtsandcrosses) shows stories loaded from a test directory and run as embeddables.
What you're missing is the <scope>test</scope> in your configuration.
The gameoflife example will also work if you move them to test directory and use configure test scope.
Cristiano, Mauro,
Many thanks!
Point taken on using the user-list - sorry.
So... I guess the maven integration-test phase doesn't include the test directory in the classpath. Makes sense.
-Ed
FWIW Edward Staub, this was helpful to me as well. Thanks for asking - even if they don't like tickets to be opened, this is searchable info on the web.
Note that the online docs are missing this <scope>test</scope> from the configuration and will not work on many projects.
Hi Edward, I don't believe that with this configuration snipped would someone figure out what is going wrong with your project. Do you ?
Why don't you create a little project that reproduce your problem and attach it here ??
regards