【问题标题】:JBehave resources not found in reports报告中未找到 JBehave 资源
【发布时间】:2017-02-10 15:27:13
【问题描述】:

当我运行我的测试项目时,报告按预期生成在目录 target/jbehave/view 中。

我的问题是找不到样式表...在目录 target/jbehave/view/style 我有一个 css jbehave.css 但生成的报告查找 jbehave-core.css

不知道是版本问题还是其他问题...

这是我在 pom.xml 中使用的依赖项:

<dependencies>
...
    <dependency>
      <groupId>org.jbehave</groupId>
      <artifactId>jbehave-core</artifactId>
      <version>${jbehave.version}</version>
    </dependency>
    <dependency>
      <groupId>org.jbehave</groupId>
      <artifactId>jbehave-spring</artifactId>
      <version>${jbehave.version}</version>
    </dependency>
    <dependency>
      <groupId>org.jbehave</groupId>
      <artifactId>jbehave-gherkin</artifactId>
      <version>${jbehave.version}</version>
    </dependency>
    <dependency>
      <groupId>org.jbehave.site</groupId>
      <artifactId>jbehave-site-resources</artifactId>
      <version>3.3</version>
      <type>zip</type>
    </dependency>
...
</dependencies>
 <build>
    <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>
        </executions>
      </plugin>
    </plugins>
  </build>

${jbehave.version} = 4.1

对于 JBehave 配置,我使用这个类:

public class TestRunner extends JUnitStories {

    @Autowired
    private ApplicationContext applicationContext;

    public TestRunner() {
        initJBehaveConfiguration();
    }

    private void initJBehaveConfiguration() {
        Class<?> thisClass = this.getClass();
        Properties properties = new Properties();
        properties.setProperty("encoding", "UTF-8");
        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("yyyy-MM-dd"))))
                .useStoryParser(new GherkinStoryParser())
                .useStepMonitor(new SilentStepMonitor()));
    }

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

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

}

【问题讨论】:

    标签: css jbehave jbehave-maven-plugin


    【解决方案1】:

    我终于成功了。

    问题来自于 pom。

    这是为我工作的一个:

    <dependencies>
      ...
      <dependency>
        <groupId>org.jbehave</groupId>
        <artifactId>jbehave-core</artifactId>
        <version>${jbehave.version}</version>
        <scope>test</scope>
      </dependency>
      <dependency>
        <groupId>org.jbehave</groupId>
        <artifactId>jbehave-spring</artifactId>
        <version>${jbehave.version}</version>
        <scope>test</scope>
      </dependency>
      <dependency>
        <groupId>org.jbehave</groupId>
        <artifactId>jbehave-gherkin</artifactId>
        <version>${jbehave.version}</version>
        <scope>test</scope>
      </dependency>
      ...
    </dependencies>
    
    
    <build>
        <plugins>
          ...
          <plugin>
            <groupId>org.jbehave</groupId>
            <artifactId>jbehave-maven-plugin</artifactId>
            <version>${jbehave.version}</version>
            <executions>
              <execution>
                <id>run-stories-as-embeddables</id>
                <phase>integration-test</phase>
                <configuration>
                  <includes>
                    <include>**/*Scenarios.java</include>
                  </includes>
                  <ignoreFailureInStories>true</ignoreFailureInStories>
                  <ignoreFailureInView>false</ignoreFailureInView>
                </configuration>
                <goals>
                  <goal>run-stories-as-embeddables</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
    
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <executions>
              <execution>
                <id>unpack-jbehave-site-resources</id>
                <phase>generate-resources</phase>
                <goals>
                  <goal>unpack</goal>
                </goals>
                <configuration>
                  <overwriteReleases>false</overwriteReleases>
                  <overwriteSnapshots>true</overwriteSnapshots>
                  <artifactItems>
                    <artifactItem>
                      <groupId>org.jbehave.site</groupId>
                      <artifactId>jbehave-site-resources</artifactId>
                      <version>3.3</version>
                      <type>zip</type>
                      <outputDirectory>${project.build.directory}/jbehave/view</outputDirectory>
                    </artifactItem>
                  </artifactItems>
                </configuration>
              </execution>
              <execution>
                <id>unpack-jbehave-reports-resources</id>
                <phase>generate-resources</phase>
                <goals>
                  <goal>unpack</goal>
                </goals>
                <configuration>
                  <overwriteReleases>false</overwriteReleases>
                  <overwriteSnapshots>true</overwriteSnapshots>
                  <artifactItems>
                    <artifactItem>
                      <groupId>org.jbehave</groupId>
                      <artifactId>jbehave-core</artifactId>
                      <version>${jbehave.version}</version>
                      <outputDirectory>${project.build.directory}/jbehave/view</outputDirectory>
                      <includes>**\/*.css,**\/*.ftl,**\/*.js</includes>
                    </artifactItem>
                  </artifactItems>
                </configuration>
              </execution>
            </executions>
          </plugin>
          ...
        </plugins>
      </build>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-07-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多