【问题标题】:JGiven show acceptance test running line by lineJGiven 逐行显示验收测试运行
【发布时间】:2017-05-18 10:11:20
【问题描述】:

是否可以使用 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 是否提供了隐藏在其代码中的任何有用的东西?

【问题讨论】:

    标签: spring acceptance-testing jgiven


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 2021-12-27
      • 2015-11-04
      • 2019-01-20
      • 1970-01-01
      • 2015-07-30
      • 1970-01-01
      • 1970-01-01
      • 2020-06-14
      • 1970-01-01
      相关资源
      最近更新 更多