我一直在尝试使用JBehave运行并发的多线程故事。它们在使用嵌入器时运行正常,但是当它们作为嵌入式运行时,它们不会执行。当我更改源目录或范围时,我得到一个nullpointerException,当我将它们注释掉时,它会成功构建,但是找不到类" My-ProgramStories.java。"当我使用Maven执行它们时,使用" mvn clean verify"这就是回归(抱歉丑陋的格式化):
[INFO] --- jbehave-maven-plugin:3.7.5:run-stories-as-embeddables(embeddable-stories)@ program-test> ---
[INFO]使用embedder将故事作为嵌入式运行 嵌入器[storyMapper = StoryMapper,storyRunner = StoryRunner, embedderMonitor = MavenEmbedderMonitor,类加载器= EmbedderClassLoader [网址= [/用户//文档/存储库///目标/测试类/, /用户//文档/存储库///目标/类, Groovy的全1.8.4.jar],父= ClassRealm [插件> org.jbehave:jbehave-行家-插件:3.7.5, parent:sun.misc.Launcher$AppClassLoader@1729854]],embedderControls = UnmodifiableEmbedderControls [EmbedderControls [批次=假,则跳过=假,generateViewAfterStories 真的,ignoreFailureInStories = TRUE,ignoreFailureInView = TRUE,verboseFailures =假, verboseFiltering =假,storyTimeoutInSecs = 400,线程= 4]] embedderFailureStrategy=org.jbehave.core.embedder.Embedder$ThrowingRunningStoriesFailed@127c1 EE,配置= org.jbehave.core.configuration.MostUsefulConfiguration @ 10c56cbd,candidateSte s = [],stepsFactory =,metaFilters = [groovy:story_path ==〜/。*。story /],systemLerities {},ExecutorService的=,executorServiceCreated =假,storyManager =]
[INFO] ----------------------------------------------- -------------------------
[INFO]建立失败
[INFO] ----------------------------------------------- -------------------------
[INFO]总时间:1:04.710s
[INFO]完成时间:Mon Jul 29 09:55:43 CDT 2013
[INFO]最终记忆:60M / 123M
[INFO] ----------------------------------------------- -------------------------
[错误]无法执行目标org.jbehave:jbehave-maven-plugin:3.7.5:run-stories-as 项目中的embeddables(embeddable-stories):无法将故事作为 embeddables:NullPointerException - > [帮助1]
这就是我在POM中配置JBehave Maven插件的方式:
<properties>
<embeddables>**/My-ProgramStories.java</embeddables>
<ignore.failre.in.stories>true</ignore.failre.in.stories>
<meta.filter>groovy: story_path ==~ /.*.story/</meta.filter>
<threads>4</threads>
<story.timeout.in.secs>400</story.timeout.in.secs>
</properties>
...
<plugin>
<groupId>org.jbehave</groupId>
<artifactId>jbehave-maven-plugin</artifactId>
<executions>
<execution>
<id>embeddable-stories</id>
<phase>integration-test</phase>
<configuration>
<includes>
<include>${embeddables}</include>
</includes>
<excludes>
<exclude>${exclude}</exclude>
</excludes>
<scope>test</scope>
<sourceDirectory>src/test/java</sourceDirectory>
<testSourceDirectory>src/test/resources</testSourceDirectory>
<skip>${skip}</skip>
<batch>false</batch>
<threads>${threads}</threads>
<storyTimeoutInSecs>${story.timeout.in.secs}</storyTimeoutInSecs>
<generateViewAfterStories>true</generateViewAfterStories>
<ignoreFailureInStories>
${ignore.failre.in.stories}
</ignoreFailureInStories>
<ignoreFailureInView>true</ignoreFailureInView>
<metaFilters>
<metaFilter>${meta.filter}</metaFilter>
</metaFilters>
</configuration>
<goals>
<goal>run-stories-as-embeddables</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>1.8.4</version>
</dependency>
</dependencies>
</plugin>
我的故事和测试类的结构以及通过Eclipse查看的故事文件如下:
我的程序检验
- &GT; SRC /测试/ JAVA
----&GT;包1
------&GT; My-ProgramSteps.java
------&GT; My-ProgramStories.java
- &GT; SRC /测试/资源
----&GT;包1
------&gt;故事档案
以下是错误的堆栈跟踪:
[错误]无法在项目my-program上执行目标org.jbehave:jbehave-maven-plugin:3.7.5:run-stories-as-embeddables(embeddable-stories):无法以可嵌入的方式运行故事:NullPointerException - &GT; [帮助1] org.apache.maven.lifecycle.LifecycleExecutionException:无法在项目my-program-test上执行目标org.jbehave:jbehave-maven-plugin:3.7.5:run-stories-as-embeddables(embeddable-stories):失败将故事作为嵌入式运行 在org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:213) 在org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) 在org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) 在org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84) 在org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59) 在org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183) 在org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161) 在org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320) 在org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156) 在org.apache.maven.cli.MavenCli.execute(MavenCli.java:537) 在org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196) 在org.apache.maven.cli.MavenCli.main(MavenCli.java:141) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 在java.lang.reflect.Method.invoke(Method.java:597) 在org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290) 在org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230) 在org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409) 在org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352) 引起:org.apache.maven.plugin.MojoFailureException:无法以可嵌入的方式运行故事 在org.jbehave.mojo.RunStoriesAsEmbeddables.execute(RunStoriesAsEmbeddables.java:20) 在org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101) 在org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209) ......还有19个 引起:java.lang.NullPointerException at org.codehaus.plexus.util.AbstractScanner.normalizePattern(AbstractScanner.java:327) 在org.codehaus.plexus.util.AbstractScanner.setExcludes(AbstractScanner.java:314) 在org.jbehave.core.io.StoryFinder.scanDirectory(StoryFinder.java:218) 在org.jbehave.core.io.StoryFinder.scan(StoryFinder.java:205) 在org.jbehave.core.io.StoryFinder.findClassNames(StoryFinder.java:61) 在org.jbehave.mojo.AbstractEmbedderMojo.classNames(AbstractEmbedderMojo.java:302) 在org.jbehave.mojo.RunStoriesAsEmbeddables.execute(RunStoriesAsEmbeddables.java:18) ......还有21个
答案 0 :(得分:0)
基于此
Caused by: java.lang.NullPointerException at
org.codehaus.plexus.util.AbstractScanner.normalizePattern(AbstractScanner.java:327) at
org.codehaus.plexus.util.AbstractScanner.setExcludes(AbstractScanner.java:314) at
看起来您的排除模式配置已损坏。它看起来像这样:
<exclude>${exclude}</exclude>
未在您的媒体资源中定义。您可以使用effective-pom来确认是否所有属性都已正确扩展。