是否可以使用 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)
即我正在寻找的是: -
- 场景方法的名称 + 所有它的、 和
given
语句when
调用_(通过 JGiven 格式格式化)。then
and
- 当每个场景方法在运行时启动时。
- 当每个
given
、和在运行when
时执行时。then
and
- 当场景方法结束时。
这将使我能够在 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 是否提供了隐藏在其代码中的任何有用的东西?