serenity-bdd - 在 Serenity 剧本报告中合并“子”可执行文件
问题描述
我创建了一个 LoginToAuth0 任务来自动化和测试我的站点登录到 Auth0 功能。
我的目标是使报告更有意义,并禁止登录凭据。Serenity 有没有办法巩固步骤而不是那么冗长(或者这与 Serenity 本身的想法背道而驰)?
如果提供一个选项来抑制报告所述组中的步骤,那么带有 groupStepName 参数的 should 方法将是完美的。
public final void should(String groupStepName, Consequence... consequences) {...}
这可能吗?也可以对atteptsTo 做同样的事情吗?
先感谢您,
蒂姆
public class LoginToAuth0 implements Task {
@Managed()
public WebDriver webDriver;
Actor actor;
public Auth0Site auth0Site;
private String email;
private String password;
protected LoginToAuth0(String email, String password) {
this.email = email;
this.password = password;
}
@Override
public <T extends Actor> void performAs(T actor) {
givenThat(actor).should(eventually(seeThat(auth0Site.isPage())),
eventually(seeThat(the(Auth0Site.loginContainer()), isCurrentlyVisible())),
eventually(seeThat(the(Auth0Site.emailField()), isCurrentlyVisible())),
seeThat(the(Auth0Site.passwordField()), isCurrentlyVisible()),
seeThat(the(Auth0Site.submitButton()), isCurrentlyVisible()));
when(actor).attemptsTo(Enter.theValue(email).into(Auth0Site.emailField()), new EnterPassword(),
Click.on(Auth0Site.submitButton()));
then(actor).should(eventually(seeThat(auth0Site.isPage(), not(true))));
}
public static class Builder {
private String email = null;
private String password = null;
public Builder withCredentials(String email, String password) {
this.email = email;
this.password = password;
return this;
}
public LoginToAuth0 build() {
if (this.email == null || this.password == null)
throw new IllegalStateException();
return Tasks.instrumented(LoginToAuth0.class, email, password);
}
}
private class EnterPassword extends SilentPerformable {
@Override
public <T extends Actor> void performAs(T actor) {
actor.attemptsTo(Enter.theValue(password).into(Auth0Site.passwordField()));
}
}
}
解决方案
You would typically group such tasks in a higher level task. You can also use the IsSilent or CanBeSilent interfaces to make tasks not appear in the reports (useful for tasks used in the givens for example)
推荐阅读
- node.js - Docker 上的 Debian 映像 - 如何安装 Nodejs
- java - 如何从 ItemTouchHelper 更新 recyclerview 数据?
- javascript - 为什么我的不会自动设置它的高度?
- javascript - 为什么我的 React setState 永远循环?
- android - 为什么我的按钮视图 ID 在运行时会发生变化?
- javascript - 如何做出反应等到检索到 api 数据
- pkg-config - 将 pkg-config 与模块环境相结合
- excel - 如何引用非连续命名范围内的特定单元格?
- routes - nextJS 深度动态路由
- reactjs - 如何使过滤和搜索协同工作?