Jbehave maven - 运行所有场景,尽管有些失败

时间:2013-12-16 15:57:39

标签: java maven jbehave

我正在运行带有注释嵌入器的运行故事的Jbehave maven插件。但是当任何场景失败时,请停止所有其他场景。但我想运行所有方案,然后针对失败的方案执行报告。有可能吗?

我将jbehave策略配置设置为SilentlyAbsorbingFailure,并且我尝试了ignoreFailureInStories选项...但它对我不起作用。我想我错过了什么。

失败时这是我的maven执行代码:

[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] Consumer Regression Test Suite .................... SUCCESS [0.591s]
[INFO] Customer Regression Test Suite Commons module ..... SUCCESS [2.678s]
[INFO] Customer Regression Test Suite Core module ........ FAILURE [25:24.539s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 25:28.081s
[INFO] Finished at: Mon Dec 16 15:42:02 CET 2013
[INFO] Final Memory: 71M/664M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.jbehave:jbehave-maven-plugin:3.7.4:run-stories-with-    annotated-embedder (embeddable-stories) on project consumer-regression-test-suite-core:     Failed to run stories with annotated embedder runner: Annotated embedder run failed with    runner org.jbehave.core.junit.spring.SpringAnnotatedEmbedderRunner@72f4abb9: Failures in   running stories:        ReportsCount[stories=2,storiesNotAllowed=0,storiesPending=0,scenarios=16,scenariosFailed=2,     scenariosNotAllowed=0,scenariosPending=0,stepsFailed=2] -> [Help 1]
 org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal     org.jbehave:jbehave-maven-plugin:3.7.4:run-stories-with-annotated-embedder (embeddable-     stories) on project consumer-regression-test-suite-core: Failed to run stories with    annotated embedder runner
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:213)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
    at 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)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: org.apache.maven.plugin.MojoFailureException: Failed to run stories with    annotated embedder runner
    at org.jbehave.mojo.RunStoriesWithAnnotatedEmbedderRunner.execute(RunStoriesWithAnnotatedEmbedderRunner.java:23)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
    ... 19 more
 Caused by: org.jbehave.core.embedder.Embedder$AnnotatedEmbedderRunFailed: Annotated    embedder run failed with runner org.jbehave.core.junit.spring.SpringAnnotatedEmbedderRunner@72f4abb9
    at org.jbehave.core.embedder.Embedder.runStoriesWithAnnotatedEmbedderRunner(Embedder.java:178)
    at org.jbehave.mojo.RunStoriesWithAnnotatedEmbedderRunner.execute(RunStoriesWithAnnotatedEmbedderRunner.java:21)
    ... 21 more
 Caused by: org.jbehave.core.embedder.Embedder$RunningStoriesFailed: Failures in running stories: ReportsCount[stories=2,storiesNotAllowed=0,storiesPending=0,scenarios=16,scenariosFailed=2,scenariosNotAllowed=0,scenariosPending=0,stepsFailed=2]
    at org.jbehave.core.embedder.Embedder$ThrowingRunningStoriesFailed.handleFailures(Embedder.java:499)
    at org.jbehave.core.embedder.Embedder.handleFailures(Embedder.java:265)
    at org.jbehave.core.embedder.Embedder.generateReportsView(Embedder.java:252)
    at org.jbehave.core.embedder.Embedder.generateReportsView(Embedder.java:233)
    at org.jbehave.core.embedder.Embedder.runStoriesAsPaths(Embedder.java:212)
    at nl.tele2.crts.core.business.configuration.CommonsStoryConfiguration.run(CommonsStoryConfiguration.java:89)
    at org.jbehave.core.embedder.Embedder.runStoriesWithAnnotatedEmbedderRunner(Embedder.java:173)
    ... 22 more
[ERROR]
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the   following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <goals> -rf :consumer-regression-test-suite-core

My Maven配置:

...

    <testResources>
        <testResource>
            <directory>src/test/resources</directory>
        </testResource>
    </testResources>

    <plugins>
        <plugin>
            <groupId>org.jbehave</groupId>
            <artifactId>jbehave-maven-plugin</artifactId>
            <version>${jbehave.version}</version>
            <executions>
                <execution>
                    <id>unpack-view-resources</id>
                    <phase>process-resources</phase>
                    <goals>
                        <goal>unpack-view-resources</goal>
                    </goals>
                </execution>
                <execution>
                    <id>embeddable-stories</id>
                    <phase>test</phase>
                    <configuration>
                        <outputDirectory>${project.build.directory}</outputDirectory>
                        <scope>test</scope>
                        <includes>
                                  <include>**/Order1Story.java</include>
                                  <include>**/Order2Story.java</include>
                                  <include>**/Order3Story.java</include>
                                  <include>**/Order4Story.java</include>
                                    </includes>
                        <generateViewAfterStories>true</generateViewAfterStories>
                    </configuration>
                    <goals>
                        <goal>run-stories-with-annotated-embedder</goal>
                    </goals>
                </execution>
            </executions>
            <dependencies>
                <dependency>
                    <groupId>log4j</groupId>
                    <artifactId>log4j</artifactId>
                    <version>1.2.16</version>
                </dependency>
            </dependencies>
        </plugin>
    </plugins>

我的故事课程:

@RunWith(SpringAnnotatedEmbedderRunner.class)
@Configure()
@UsingEmbedder(embedder = Embedder.class, generateViewAfterStories = true,     ignoreFailureInStories = false, ignoreFailureInView = false, storyTimeoutInSecs = 1200)
@UsingSpring(resources = { "classpath:crts-application-context.xml",
                          "classpath:steps/dsl/crts-jbehave-commons-dsl-configuration-    steps.xml",
                          "classpath:steps/dsl/crts-jbehave-order-dsl-steps-    context.xml" })
public class Order1Story extends CommonsStoryConfiguration {

protected List<String> storyPaths() {
    return new     StoryFinder().findPaths(codeLocationFromClass(this.getClass()).getFile(),
            asList("**/" + System.getProperty("storyFilter", "*") + "order/dsl/order-  1P-dsl*.story"), null);
   }

}

配置类:

public abstract class CommonsStoryConfiguration extends InjectableEmbedder {

@Test
public void run() throws Throwable {

    final CrossReference crossReference =
            new   CrossReference().withJsonOnly().withOutputAfterEachStory(true).excludingStoriesWithNoExecutedScenarios(true);

    final SeleniumContext seleniumContext = new SeleniumContext();

    // Step Monitor
    // final ContextView contextView = new LocalFrameContextView().sized(640, 120);
    // final SeleniumStepMonitor stepMonitor = new SeleniumStepMonitor(contextView,
    // seleniumContext, crossReference.getStepMonitor());

    // Formatting
    final Format[] formats = new Format[] { new SeleniumContextOutput(seleniumContext), CONSOLE, HTML };

    // StoryRporterBuilder
    final StoryReporterBuilder reporterBuilder = new StoryReporterBuilder();
    reporterBuilder.withCodeLocation(codeLocationFromClass(CommonsStoryConfiguration.class));
    reporterBuilder.withFailureTrace(true);
    reporterBuilder.withFailureTraceCompression(true);
    reporterBuilder.withDefaultFormats();
    reporterBuilder.withFormats(formats);
    reporterBuilder.withCrossReference(crossReference);

    // PatternParser
    final RegexPrefixCapturingPatternParser stepPatternParser = new RegexPrefixCapturingPatternParser("$");

    // Parameter converter
    final DateConverter dateConverter = new DateConverter(new SimpleDateFormat("yyyy-MM-dd"));
    final ParameterConverters parameterConverters = new ParameterConverters();
    parameterConverters.addConverters(dateConverter);

    // Failure Strategy
    final FailureStrategy strategy = new SilentlyAbsorbingFailure();

    // Story Control
    final StoryControls storyControls = new StoryControls();
    storyControls.doDryRun(false);
    storyControls.doSkipScenariosAfterFailure(false);

    // Configuration
    final Configuration configuration = injectedEmbedder().configuration();
    configuration.useStoryLoader(new LoadFromClasspath(CommonsStoryConfiguration.class));
    configuration.useStoryReporterBuilder(reporterBuilder);
    configuration.useStepPatternParser(stepPatternParser);
    configuration.useParameterConverters(parameterConverters);
    configuration.useFailureStrategy(strategy);
    configuration.useStoryControls(storyControls);
    // configuration.useStepMonitor(stepMonitor);

    injectedEmbedder().runStoriesAsPaths(storyPaths());

}

protected abstract List<String> storyPaths();

}

提前致谢,

1 个答案:

答案 0 :(得分:0)

对于继续运行方案,请设置

ignoreFailureInStories =真

请参阅How do I make JBehave ignore failed scenarios?