2017-09-08 1 views
0

JBehave의 기본 HTML Story Reports에는 실행되는 시나리오의 수, GiventStory 시나리오의 수 및 단계가 표시됩니다.JBehave HTML 보고서 - 실행되는 스토리의 수를 표시하는 방법

내가하려는 것은 실행할 정보의 수를 표시하기 위해 정보를 추가하는 것입니다.

예를 들어 시나리오가 3 개이면 시나리오가 3 개 실행됩니다. 실제로 그것은 테이블에 하나의 시나리오 만 표시하고 실행 한 3 개의 스토리에 대한 새로운 컬럼을 원합니다.

있습니다 내 실제 구성입니다 :

public class JBehaveStoryRunner extends JUnitStories { 

    @Autowired 
    private ApplicationContext applicationContext; 

    public JBehaveStoryRunner() { 
     Class<?> thisClass = this.getClass(); 
     Properties properties = new Properties(); 
     properties.setProperty("encoding", "UTF-8"); 
     // @formatter:off 
     useConfiguration(new MostUsefulConfiguration() 
       .useStoryLoader(new LoadFromClasspath(thisClass.getClassLoader())) 
       .usePendingStepStrategy(new FailingUponPendingStep()) 
       .useStepdocReporter(new PrintStreamStepdocReporter()) 
       .useStoryReporterBuilder(new StoryReporterBuilder() 
         .withCodeLocation(CodeLocations.codeLocationFromClass(thisClass)) 
         .withDefaultFormats() 
         .withFormats(Format.CONSOLE, Format.TXT, Format.HTML, Format.XML, Format.STATS) 
         .withCrossReference(new CrossReference()) 
         .withViewResources(properties) 
         .withFailureTrace(true)) 
       .useParameterConverters(new ParameterConverters() 
         .addConverters(new ParameterConverters.DateConverter(new SimpleDateFormat("dd-MM-yyyy")))) 
       .useStoryParser(new GherkinStoryParser()) 
       .useParameterControls(new ParameterControls().useNameDelimiterLeft("[").useNameDelimiterRight("]")) 
       .useStepMonitor(new SilentStepMonitor())); 
     // @formatter:on 
    } 

    @Override 
    public InjectableStepsFactory stepsFactory() { 
     return new SpringStepsFactory(configuration(), applicationContext); 
    } 

    protected List<String> storyPaths() { 
     return new StoryFinder().findPaths(CodeLocations.codeLocationFromClass(this.getClass()), "**/*.story", "**/excluded*.story"); 
    } 
} 

답변

1

이 HTML 보고서를 this (jbehave-reports.ftl) Freemaker 템플릿을 사용하여 생성됩니다. 이 보고서에 새 필드를 추가하려면이 템플릿을 사용자 지정하거나 자신 만의 복사본을 만들어야합니다.

Freemaker를 모르거나 배울 시간이 없기 때문에 개인적으로 XML 파일을 사용합니다 (Format.XML을 사용하면 생성됩니다).
XML 파일에는 필요한 모든 정보가 포함되어 있으며이를 분석하고 보고서에 표시 할 요소를 계산합니다.

이 아래의 예를 이야기에 대해 생성 된 데이터의 예입니다 (Maven을 기반으로 프로젝트 : JBehave의-단순 원형) :

Scenario: A scenario with some pending steps 

Given I am a pending step <Step> 
When a good soul will implement me 
Then I shall be happy <Val> 
Examples: 
|Step|Val| 
|1|1| 
|2|2| 
내가 생각 한 방법
<story path="org/irko/my_jbehave_simple/stories/my.story" title=""> 
    <scenario keyword="Scenario:" title="A scenario with some pending steps"> 
     <examples keyword="Examples:"> 
      <step>Given I am a pending step &lt;Step&gt;</step> 
      <step>When a good soul will implement me</step> 
      <step>Then I shall be happy &lt;Val&gt;</step> 
      <parameters> 
       <names> 
        <name>Step</name> 
        <name>Val</name> 
       </names> 
       <values> 
        <value>1</value> 
        <value>1</value> 
       </values> 
       <values> 
        <value>2</value> 
        <value>2</value> 
       </values> 
      </parameters> 

      <example keyword="Example:">{Step=1, Val=1}</example> 
      <step outcome="successful"> 
       Given I am a pending step 
       <parameter>1</parameter> 
      </step> 
      <step outcome="successful">When a good soul will implement me</step> 
      <step outcome="successful"> 
       Then I shall be happy 
       <parameter>1</parameter> 
      </step> 

      <example keyword="Example:">{Step=2, Val=2}</example> 
      <step outcome="successful"> 
       Given I am a pending step 
       <parameter>2</parameter> 
      </step> 
      <step outcome="successful">When a good soul will implement me</step> 
      <step outcome="successful"> 
       Then I shall be happy 
       <parameter>2</parameter> 
      </step> 
     </examples> 
    </scenario> 
</story> 
+0

하지만 더 쉬운 방법이 있기를 바랐다. – bryce

관련 문제