标签:comment 期望 eve ext play private blog cli ide
2017-09-28
script | login dialog driver | Bob | xyzzy | |
login with username | Bob | and password | xyzzy | |
check | login message | Bob logged in. | ||
reject | login with username | Bob | and password | bad password |
check | login message | Bob not logged in. | ||
check not | login message | Bob logged in. | ||
ensure | login with username | Bob | and password | xyzzy |
note | this is a comment | |||
show | number of login attempts | |||
$symbol= | login message |
源代码:
public class LoginDialogDriver { private String userName; private String password; private String message; private int loginAttempts; public LoginDialogDriver(String userName, String password) { this.userName = userName; this.password = password; } public boolean loginWithUsernameAndPassword(String userName, String password) { loginAttempts++; boolean result = this.userName.equals(userName) && this.password.equals(password); if (result) message = String.format("%s logged in.", this.userName); else message = String.format("%s not logged in.", this.userName); return result; } public String loginMessage() { return message; } public int numberOfLoginAttempts() { return loginAttempts; } }
说明:
很明显,这个表中每一行都是一条指令。
Script:login dialog driver | Bob | xyzzy |
第一行Script后面跟的是类名LoginDialogDriver和构造函数的参数Bob,xyzzy,这一行称之为actor,如果table中没有actor,就沿用上一个table的actor。
Script table 调用方法可以插入式调用,即方法和参数是相间的,如下所示:
login with username | Bob | and password | xyzzy |
也可以连续调用,可以在单元格方法名后面添加分号,然后紧接的单元格都是入参,如下所示:
login with username and password; | Bob | xyzzy |
标签:comment 期望 eve ext play private blog cli ide
原文地址:http://www.cnblogs.com/Ming8006/p/7606860.html