[Feature] Add custom description to assertThat and/or Locator naming

未关闭
#954 1 条评论 4 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
25/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
停滞
技术栈
java, playwright
领域
testing-qa

调研方向

首先阅读 PlaywrightAssertions API,以及 issue 中引用的 Locator、Page 和 ApiResponse 类型。比较所请求的断言级和对象级命名示例,然后定义一种一致的受支持方案,使其失败消息包含自定义描述或名称。

由索引模型根据 Issue 内容生成。

描述

P3-collecting-feedback

With assertJ, we can add a custom name for given asserted object, for example:

Assertions.assertThat(mansion.guests()).as("Living Guests").isEqualTo(7);

Will result in:

[Living Guests] expected:<[7]> but was<[6]>

Selenide comes with element-aliasing as well as the .because() call (that does the similar thing, but not on asserted element, but the assertion itself):

$("div >> span").as("Living Guests").shouldHaveSize(7).because("The guest count should be valid")

The playwright-java assertions would be more readable if we'd be able to do similar thing with PlaywrightAssertions.assertThat or even the Locator/Page/ApiResponse itself, e.g.:

// on assertion:
PlaywrightAssertions.assertThat(questCount).hasText("7").because("The guest count should be valid");
// on asserted object:
PlaywrightAssertions.assertThat(questCount).as("Living Guests").hasText("7");
// on Locator
Locator guestCount = page.locator("div >> span").as("Living Guests");
主要语言
Java
星标
1.6k
派生
298
平均合并
3 天 2 小时
30 天内合并 PR
14

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

microsoft/playwright-java 的其他 Issue

查看 microsoft/playwright-java 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。