Fitnesse 之 Script Table
在表中每一行代表一个执行脚本。
第一行中的Script关键字表明表格类型,后面紧跟着类名(Fixture)和构造函数中的参数。在一个测试页中如果没有再指定其它Fixture,将一直沿用上一个Fixture。
(1)Fixture调用方法
| script | login dialog driver | Bob | xyzzy | |
或者
| Script:login dialog driver | Bob | xyzzy |
(2)函数调用
Most instructions involve some kind of function call. By default, the name of the function is assembled from tokens in every other cell. The arguments of the function are the intervening cells. Appending ";" to the end of a function name in a cell invokes sequential argument processing, which means that the arguments to the function are all subsequent cells.
函数调用有两种方法
1. Interposing Function Call (Default) 插入函数调用(默认)
| login with username | Bob | and password | xyzzy |
2. Sequential Argument Processing Function Call顺序参数处理函数调用
| login with username and password; | Bob | xyzzy |
注意:这种方式需要在函数名后追加一个“;”。
(2)行操作和显示
1. 如果一个行中只单独存在一个函数,如果这个函数返回值是布尔值,那么该行将变成红色(false)或者绿色(true),其他的保持本色。
2. 关键字:
|
第一个行单元格 |
类型 |
|
|
check |
返回匹配情况 |
后面紧跟着一个函数,行最后一个单元格将被作为预期值,与函数的返回值进行匹配,匹配为true,不匹配为false |
|
check out |
返回不匹配情况 |
后面紧跟着一个函数,行最后一个单元格将被作为非预期值,与函数的返回值进行匹配,匹配为false,不匹配为true(与check相反) |
|
ensure |
布尔值 |
后面紧跟着一个函数,这个函数必须返回一个布尔值。如果是false,行为红色,如果是true,行为绿色。 |
|
reject |
(非)布尔值 |
后面紧跟着一个函数,这个函数必须返回一个布尔值。如果是false,行为绿色,如果是true,行为红色。(和正常的显示相反) |
|
note/blank/以#和*开头的单词 |
忽略 |
表示忽略该行 |
|
show |
展示 |
后面紧跟着一个函数,在函数被执行后,该行的最后面将被增加一个单元格,用于展示函数的返回值。 |
|
Symbol(标识符) |
变量 |
和$符连用,它将存储后面函数的返回值 |
|
start |
新建 |
后面紧跟着另一个Fixture以及构造函数参数,它将代替前面的Fixture,下面的行将使用新的Fixture。 |
例子:
Fixture代码:
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 | |
| 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 | |||
表格说明:
第一行:创建LoginDialogDriver对象
第二行:调用loginWithUsernameAndPassword方法
第三行:调用loginMessage方法,对比当前的登录信息是否是Bob logged in
第四行:调用loginWithUsernameAndPassword方法,使用的是错误的密码
第五行:调用loginMessage方法,对比当前的登录信息是否是Bob not logged in
第六行:调用loginMessage方法,对比当前的登录信息是否不是Bob logged in
第七行:调用loginWithUsernameAndPassword方法,判断返回值
第八行:忽略该行
第九行:调用numberOfLoginAttempts,并在该行的最后面将被增加一个单元格,展示返回值。
第十行:调用loginMessage方法,并将登录信息保存到变量symbol中
以上内容源自FitNesse.FullReferenceGuide.UserGuide.WritingAcceptanceTests.SliM.ScriptTable
Fitnesse 之 Script Table的更多相关文章
- 介绍并扩展Fitnesse的测试模块化机制:ScenarioTable
摘要:在验收测试框架Fitneese中,使用Scenario可以把最常用的测试步骤封装起来,从而达到模块化定义Fitnesse测试用例的能力.但Scenario仅限于封装Script测试步骤,Scri ...
- fitnesse - 一个简单的例子(slim)
fitnesse - 一个简单的例子(slim) 2017-09-30 目录1 编写测试代码(Fixture code)2 编写wiki page并运行 2.1 新建wikiPage 2.2 运行 ...
- Fitnesse - Slim Tables
Fitnesse - Slim Tables 2017-09-28 目录1 什么是Wiki Word?2 Query Table 2.1 Query Table的格式 2.2 源代码3 Scri ...
- Fitnesse框架简单介绍
1.Fitnesse是什么? 官方的说明:FitNesse is a wiki server. It's also a test execution engine. Fitnesse是一个wiki s ...
- Fitnesse Slim的使用
官网上的使用说明:http://www.fitnesse.org/FitNesse.UserGuide.WritingAcceptanceTests.Slim 本文主要介绍Slim常用的几种表格,更多 ...
- IE 中单元格的 colspan 属性在某些情况下会影响 TABLE 元素的自动布局
今天在写一个jsp页面时,遇到一个如下的问题:在一个table中写了如下内容,table中定义了4列,在firefox中能正常显示,而在ie8中,显示不正常, 如下如图1:第二,三,四列宽度发生变化, ...
- 简单的css js控制table隔行变色
(1)用expression 鼠标滑过变色: <style type="text/css"><!-- table { background-color:#0000 ...
- ie8下table的colspan属性与max-with属性的显示错乱问题
今天项目测试时发现了一个table的colspan样式问题,发现colspan单元格下的的元素设置max-with后将上面的第二列单元格撑开了,导致后面单元格的内容换行,先看代码: html代码: & ...
- css控制table的td宽度
今天发现即使设置table的td.th宽度,仍是不管用,是根据table的td的内容来适应宽度,导致其他的th.td丢失. 下图就是浏览器渲染的table,导致缺失"端口"这一列, ...
随机推荐
- thttpd源代码解析 定时器模块
thttpd源代码解析 定时器模块 thttpd是很轻量级的httpserver,可运行文件仅50kB.名称中的第一个t表示tiny, turbo, 或throttling 与lighttpd.mem ...
- Android-addToBackStack使用和Fragment执行流程
文章来源:https://blog.csdn.net/wenxuzl99/article/details/16112725 在使用Fragment的时候我们一般会这样写: FragmentTransa ...
- vue http 请求
https://github.com/vuejs/awesome-vue#http-requests vue-resource - npm https://www.npmjs.com/package/ ...
- File syncing and sharing software with file encryption and group sharing, emphasis on reliability and high performance.
http://seafile.com/ showdoc haiwen/seafile: File syncing and sharing software with file encryption a ...
- ios怎样在一个UIImageButton的里面加一些自己定义的箭头
能够採用例如以下方法,写一个函数: -(UIImage*) getOneImageButtonWithArrow{ //tmpView做附控件 UIView *tmpView = [[UIView a ...
- 拓展gcd求不定方程通解
void gcd(LL a,LL b,LL &d,LL &x,LL &y){ ){d=a;x=;y=;return;} gcd(b,a%b,d,x,y); int t=x; x ...
- Android 如何永久性开启adb 的root权限【转】
本文转载自:https://www.2cto.com/kf/201702/593999.html adb 的root 权限是在system/core/adb/adb.c 中控制.主要根据ro.secu ...
- javabean学习
javabean是一种可重复使用且跨平台的软件组件.他可以分为:客户界面组件(UI,user interface)和没有用户界面,主要负责处理事务(如,数据处理.操作数据库等)地javabean ja ...
- HDFS副本设置——默认3
首先 dfs.replication这个参数是个client参数,即node level参数.需要在每台datanode上设置. 其实默认为3个副本已经够用了,设置太多也没什么用. 一个文件,上传到h ...
- Yii 表单验证规则---总结
Filter: 过滤,'filter'=>'trim',表示去空格 Required:必须的,表示不能为空 Match: 匹配正则,需要和pattern一起使用,定义正则表达式,'pattern ...