简体   繁体   English

Jbehave maven-运行所有方案,尽管有些失败

[英]Jbehave maven - Run all the scenarios although some fail

I'm running Jbehave maven plugin with run-stories-with-annotated-embedder. 我正在运行Jbehave Maven插件,并带有带注释的嵌入式嵌入程序。 But when any scenario fails, then stop all the other scenarios. 但是,当任何方案失败时,请停止所有其他方案。 But I would like to run all the scenarios and then do a report with the scenarios that fails . 但是我想运行所有方案,然后针对失败的方案进行报告 Is it possible to do this ?? 是否有可能做到这一点 ??

I setup the jbehave strategy configuration to SilentlyAbsorbingFailure, and also I tryed ignoreFailureInStories option... but it dosen't work for me. 我将jbehave策略配置设置为SilentlyAbsorbingFailure,也尝试了ignoreFailureInStories选项...但是它对我不起作用。 I think I am missing something. 我想我缺少了一些东西。

This is my maven execution code when fails: 这是我的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 configuration: 我的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>

My Story class: 我的故事课:

@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);
   }

}

Configuration class: 配置类:

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();

}

Thanks in advance, 提前致谢,

For continue running scenarios, set 对于继续运行的方案,请设置

ignoreFailureInStories=true ignoreFailureInStories = true

See How do I make JBehave ignore failed scenarios? 请参阅如何使JBehave忽略失败的方案?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM