You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

测试用例执行成功后Serenity BDD报告未生成问题求助

Troubleshooting Serenity BDD Report Generation Issues

Hi AnnieC, let's work through your problem step by step to get those Serenity reports generating properly, both locally in Eclipse and on Jenkins.

1. Critical Version Compatibility Issue

The first red flag is your version mismatch between Serenity core and the Serenity-JBehave integration:

  • You're using serenity.version=1.8.21 but serenity.jbehave.version=1.35

Serenity-JBehave versions are tightly coupled to the core Serenity version. For Serenity 1.8.x, you should use a 1.8.x version of serenity-jbehave (e.g., 1.8.30, the latest in the 1.8.x line). Using a mismatched version like 1.35 will break the report generation pipeline, as the integration won't properly communicate with core Serenity libraries.

Update your pom.xml to align these versions:

<properties>
  <serenity.version>1.8.30</serenity.version>
  <serenity.jbehave.version>1.8.30</serenity.version>
  <!-- Keep other versions as is unless you need to update them -->
</properties>

2. Fix Serenity Properties Configuration

Your serenity.properties has two issues that might block report generation:

  • The serenity.test.root value has quotes and a space (Java package names can't have spaces!). If your test package is net.bddproject (or similar), remove the quotes and fix the package name:
    serenity.test.root = net.bddproject
    
  • The serenity.outputDirectory setting changes where reports are saved, but I'd recommend removing this line first to use the default target/site/serenity directory. Get basic reports working first, then adjust the path if needed.

3. Verify Maven Build Goals & Plugin Configuration

Correct Build Goal

For Serenity-JBehave projects, the standard build goal to run tests and generate reports is:

clean verify

The serenity:aggregate goal is usually included automatically by the Serenity Maven plugin when you run verify, so adding it explicitly might cause conflicts. Try running just clean verify in Eclipse first.

Check Failsafe Plugin Configuration

Ensure your maven-failsafe-plugin is configured to pick up JBehave test classes:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-failsafe-plugin</artifactId>
  <version>2.18</version>
  <executions>
    <execution>
      <goals>
        <goal>integration-test</goal>
        <goal>verify</goal>
      </goals>
      <configuration>
        <includes>
          <include>**/*Stories.java</include>
        </includes>
      </configuration>
    </execution>
  </executions>
</plugin>

Make sure your test classes (the ones that run JBehave stories) follow the *Stories.java naming pattern.

Add Serenity JBehave Maven Plugin

You might be missing the plugin that ties JBehave test execution to Serenity's report generation. Add this to your pom.xml:

<plugin>
  <groupId>net.serenity-bdd.maven.plugins</groupId>
  <artifactId>serenity-jbehave-maven-plugin</artifactId>
  <version>${serenity.jbehave.version}</version>
  <executions>
    <execution>
      <id>stories</id>
      <phase>integration-test</phase>
      <goals>
        <goal>run-stories-as-tests</goal>
      </goals>
    </execution>
  </executions>
</plugin>

4. Ensure Tests Are Actually Executing

The empty index.html in target/jbehave/view suggests no test stories were executed or captured. Check your Eclipse console for lines like "Running net.bddproject.MyStories" or counts of scenarios/steps run. If no tests run:

  • Verify story files are in src/test/resources/stories
  • Ensure your test classes correctly reference the story files
  • Confirm step definitions are annotated with @Given, @When, @Then and match story syntax

5. Jenkins Configuration Fixes

Once local reports work:

  1. Push your fixed pom.xml and serenity.properties to Git so Jenkins pulls the updated code.
  2. In Jenkins, update the "Publish HTML reports" step to point to the correct directory:
    • Default path: target/site/serenity
    • If using a custom path: use your serenity.outputDirectory value
  3. Ensure Jenkins has read/write permissions to the workspace directory (file system permissions can block report generation).

Key Questions Answered

  • Version issue? Yes, the mismatched Serenity core and Serenity-JBehave versions are a major cause of your problem.
  • Manual report path configuration? Yes, you can use serenity.outputDirectory, but get default reports working first before customizing.
  • Will Jenkins generate reports if Eclipse does? Yes, once your local build works, Jenkins (pulling the same code) will generate reports too, as long as build steps and paths are configured correctly.

Don't hesitate to dig into Maven build logs for subtle errors—sometimes the issue is a missing dependency or misnamed file that's easy to overlook.

内容的提问来源于stack exchange,提问作者AnnieC

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.08 16:47:54