gpt4 book ai didi

serenity-bdd - 如何自定义 Serenity BDD 的报告

转载 作者:行者123 更新时间:2023-12-04 23:40:29 49 4
gpt4 key购买 nike

我希望更改 Serenity 报告中的 CSS 和 Logo 。此外,我想在 Serenity 报告中添加一些自定义文本或一些测试的链接。就像生成了一个 excel 报告,我希望在报告的测试步骤中提供它的链接。实现这一目标的最佳方法是什么?

最佳答案

我找到了一种更好、更简洁的方式来自定义 Serenity 报告。基本上,我们可以生成我们自己的具有不同版本号的 Serenity-reports-resources 项目,并将我们的项目配置为使用我们自定义的报告资源构建而不是官方报告资源。执行此操作的设置如下:

  • 下载来源:
    https://github.com/serenity-bdd/serenity-core.git
  • 修改构建 Gradle 设置以生成您自己的“serenity-report-resources”jar 文件。打开“build.gradle”文件。
    2.1 将“mavenLocal()”添加到存储库:
    buildscript {
    repositories {
    mavenLocal()
    .....

    2.2 添加Maven发布插件
    apply plugin: 'maven-publish'

    2.3 更改子项目版本号。换行:
    version = rootProject.version

    为了
    version = '0.0.0.1'

    注意:使用您想要的版本号来跟踪报告站点的更改。
  • 运行
    mvn clean build
    对于子项目“ Restful 报告资源”

    3.1 运行
    publishing / publishToMavenLocal
    将您的报告站点安装为本地存储库中的新 Maven 依赖项。在其他环境中运行测试时,将此构建发布或部署到您需要的地方。
  • 将您的项目配置为不包含官方的“serenity-report-resources”依赖项并添加您的。

  • 4.1 在依赖项部分添加没有报告的 serenity-core。
    <dependency>
    <groupId>net.serenity-bdd</groupId>
    <artifactId>serenity-core</artifactId>
    <version>${serenity.version}</version>
    <exclusions>
    <exclusion>
    <groupId>net.serenity-bdd</groupId>
    <artifactId>serenity-report-resources</artifactId>
    </exclusion>
    </exclusions>
    </dependency>

    4.2 添加您的自定义报告依赖项。使用您之前使用的相同版本号。
    <dependency>
    <groupId>net.serenity-bdd</groupId>
    <artifactId>serenity-report-resources</artifactId>
    <version>0.0.0.1</version>
    </dependency>

    4.3 配置 serenity 插件依赖项以使用您的自定义报告构建。
    <!-- Serenity plugin -->
    <plugin>
    <groupId>net.serenity-bdd.maven.plugins</groupId>
    <artifactId>serenity-maven-plugin</artifactId>
    <version>${serenity.maven.version}</version>
    <dependencies>
    <dependency>
    <groupId>net.serenity-bdd</groupId>
    <artifactId>serenity-core</artifactId>
    <version>${serenity.version}</version>
    <exclusions>
    <exclusion>
    <groupId>net.serenity-bdd</groupId>
    <artifactId>serenity-report-resources</artifactId>
    </exclusion>
    </exclusions>
    </dependency>
    <dependency>
    <groupId>net.serenity-bdd</groupId>
    <artifactId>serenity-report-resources</artifactId>
    <version>0.0.2</version>
    </dependency>
    </dependencies>
    <executions>
    <execution>
    <id>serenity-reports</id>
    <phase>post-integration-test</phase>
    <goals>
    <goal>aggregate</goal>
    </goals>
    </execution>
    </executions>
    </plugin>

    现在,当您使用“SerenityRunner”运行测试时,它应该会找到您的自定义报告构建的资源,而不是官方的 serenity 报告构建。

    如果我们可以将生成报告所需的资源位置配置为来自同一框架的静态或系统属性,那就更好了。让我们看看我能做什么:-)

    我希望它有所帮助,
    继续黑客

    关于serenity-bdd - 如何自定义 Serenity BDD 的报告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39025017/

    49 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com