Maven Goals

JBehave supports accessing the Embedder functionality via Maven goals:

Maven goals support the following properties:

  • sourceDirectory: defaults to src/main/java
  • testSourceDirectory: defaults to src/test/java
  • outputDirectory: defaults to target/classes
  • testOutputDirectory: defaults to target/test-classes
  • scope: [compile|test], defaults to compile
  • includes: list of include patterns
  • excludes: list of exclude patterns
  • metaFilters: list of meta filters
  • systemProperties: list of system properties to set during execution
  • batch: [true|false], defaults to false
  • skip: [true|false], defaults to false
  • ignoreFailureInStories: [true|false], defaults to false
  • ignoreFailureInView: [true|false], defaults to false
  • generateViewAfterStories: [true|false], defaults to true
  • storyTimeoutInSecs: defaults to 300
  • storyTimeoutInSecsByPath: defaults to 300 (the default of storyTimeoutInSecs)
    • Overrides the default value in storyTimeoutInSecs, and can be expressed as a CSV of regex
      expressions matching story paths. E.g. "*/long/.story:5000,*/short/.story:200,*/medium/m_story.story:1000"
  • failOnStoryTimeout: [true|false], defaults to false
  • threads: defaults to 1
  • embedderClass: defaults to Embedder.
  • injectableEmbedderClass: defaults to null
  • storyFinderClass: defaults to StoryFinder
Performance Testing: You can make use of storyTimeoutInSecs and storyTimeoutInSecsByPath to ensure tests run under the time(s) specified

In addition, the unpack-view-resources goal supports the properties:

  • resourceArtifactIds: list of resource artifactIds, optional (defaults to {"jbehave-site-resources", "jbehave-core"})
  • resourceTypes: list of resource types, optional (defaults to {"zip"})
  • resourceIncludes: the pattern of includes when unpacking each resource, optional (defaults to includes all)
  • resourceExcludes: the pattern of excludes when unpacking each resource, optional (defaults to excludes none)
  • viewDirectory: the output directory of the resources, optional (defaults to the one configured in the Embedder StoryReporterBuilder)

An example of a typical Maven plugin usage is:

The default scope is compile, which means that the stories will be looked up in the POM source directory. If the scope is set to test the stories will be looked up in the POM test source directory.

ClassLoading Logging Frameworks

JBehave uses FreeMarker to generate template-based reports. FreeMarker uses its own version of a logging facade framework which auto-discovers different logging frameworks, notably SLF4J, JDK Logging and Apache Log4J. When using the JBehave Maven Plugin, and depending on the rest of your POM configuration, you may need to add SLF4J Log4J bridge and Apache Log4J2 as Plugin Dependency (as opposed to the Project Dependency) if you find that it's not able to load its classes, e.g.:

ClassLoading Groovy Meta Matcher

When using the JBehave Maven Plugin with a Groovy Meta Matcher you need to configure Groovy as Plugin Dependency (as opposed to the Project Dependency):