gpt4 book ai didi

spring - JGiven 逐行显示验收测试运行

转载 作者:行者123 更新时间:2023-12-01 16:05:01 25 4
gpt4 key购买 nike

是否可以使用 JGiven(有或没有 Spring 支持)在执行之前/期间检索语句?例如,如果我们有一个相当典型的登录验收测试,即

public class LoginFeatureTest extends SpringScenarioTest<GivenIAmAtTheLoginPage, WhenILogin, ThenTheLoginActionWillBeSuccessful> {

@Test
public void my_login_test() {

given().I_am_a_new_user()
.and().I_am_at_the_login_page();

when().I_login_with_username_$_and_password_$("dave", "dave123");

then().the_home_page_is_visible();

}

}

是否有可能获得对以下信息的访问权限?

My Login Test (start)
Given I am a new user
and I am at the login page
When I login with username dave and password dave123
Then the home page is visible
My Login Test (end)

即我正在寻找的是:-

  1. 场景方法的名称 + 所有它的 givenwhenthenand 语句调用 _ (通过 JGiven 格式进行格式化)。
  2. 当每个场景方法在运行时启动时。
  3. 当每个 givenwhenthenand 在运行时执行。
  4. 场景方法结束时。

这将使我能够在 UI 中直观地显示 (a) 将要执行的内容以及 (2) 它在执行期间的当前位置(带有持续时间)。

12:00:01.012         [ My Login Test (start) ]
12:00:02.035 23ms Given I am a new user
12:00:02.051 16ms and I am at the login page
----> When I login with username dave and password dave123
Then the home page is visible
[ end ]

我在想 Spring AOP 可能会拯救这里?或者 JGiven 是否提供了隐藏在其代码中的任何有用信息?

最佳答案

目前还不可能做到这一点。我为此创建了一个问题:https://github.com/TNG/JGiven/issues/328 .

实现这个应该不会太困难,因为内部已经有一个监听器概念。如果您仍然感兴趣,您可以提出一个 API 并将该机制集成到 JGiven 中。

关于spring - JGiven 逐行显示验收测试运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44044898/

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