是否可以使用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
,then
和and
语句调用_(通过JGiven格式化格式化)。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是否提供了埋藏在其代码中的任何有用的东西?
答案 0 :(得分:0)
目前没有可能这样做。我为此创建了一个问题:https://github.com/TNG/JGiven/issues/328。
实现它应该不会太难,因为内部已经有了一个监听器概念。如果您仍然感兴趣,可以提出一个API并将该机制集成到JGiven中。