FIT是fitnesse使用的默认的引擎(SLIM的使用在上一篇文章中说明),不需要特别声明即可使用执行表格测试,所有编写的fixture都需要继承Fit的Fitxture

编写测试用例前需要先声明class或者jar包所在的路径,才能找到所需要的fixture

使用关键字path

1. Column Fixture

这是使用最多的,每一行代表输入或者期望输出,添加?的代表调用的输出方法,如果期望值和实际输出值一致,则显示绿色,否则显示红色,并且显示实际输出值。如果添加的是()表示返回值,值的颜色是灰色;addRemovePayerFixture在包fixture下,调用的时候需要加上包路径

源码:

public class AddRemovePlayerFixture extends ColumnFixture {

private String playerName;

private Game theGame;

public void setPlayerName(final String playerName) {

this.playerName = playerName;

}

public boolean addPlayer() {

this.theGame = StaticGame.theGame;

Player thePlayer = this.theGame.addPlayer(this.playerName);

return this.theGame.playerIsPlaying(thePlayer);

}

public int countPlayers() {

return this.theGame.getNumberOfPlayers();

}

}

输入的playerName会调用set方法载入输入值

2. Row Fixture

用于查询数据的fixture,只要输入了查询的条件就可以获得返回,也可以校验输出的返回值,这种表格适用于查询数据

源码

public class EmployeePayRecordsRowFixture extends RowFixture {

public Object[] query() throws Exception {

EmployeePayRecord[] records = new EmployeePayRecord[2];

records[0] = new EmployeePayRecord(1, 1000, "Bob");

records[1] = new EmployeePayRecord(2, 2000, "Jack");

return records;

}

public Class getTargetClass() {

return EmployeePayRecord.class;

}

}

public class EmployeePayRecord {

public int id;

private double salary;

public String name;

public EmployeePayRecord(final int id, final double salary, final String name) {

this.id = id;

this.salary = salary;

this.name = name;

}

public double pay() {

return this.salary;

}

}

fixture先通过getTargetClass()加载查询的数据对象,然后通过query获得查询结果,整个fixture的作用就是组装数据,

查询的时候从左往右匹配条件,如果前面的列值没有找到对应的数据,则会标记为fail,查询结果中,没有期望的值,则会标记为miss,期望值不在查询结果中,则会标记为surplus

3. Action Fixture

当想要操作一系列的方法的时候,可以使用该fixture

操作的类型主要有三种enter,press,check

enter: 一般适用于set方法,把期望的值传递给fixture

press:执行方法,参数可选

check:需要输入期望值

源码:

public class CountFixture extends Fixture {

private int counter = 0;

public void count() {

this.counter++;

}

public int counter() {

return this.counter;

}

public void setCounter(final int num) {

this.counter = num;

}

}

4.Table Fixture

当fit提供的fixture不能满足需要的时候,可以使用table fixture,该fixture可以自由处理表格单元格的

(0,0)表示左上角第一个单元格

(row,column)都是从0开始

Table fixture的方法

protected abstract void doStaticTable(int rows)

Table   Fixture is an abstract class that   you must derive from. You must override doStaticTable to perform the   functions of the fixture. The number of rows in the table is passed in rows.

protected Parse getCell(int row, int column)

Returns the addressed table   cell as a Parse.

protected String getText(int row, int column)

Returns the text within the   addressed table cell.

protected boolean blank(int row, int column)

Returns true if the   addressed table cell is blank.

protected void wrong(int row, int column)

Turns the addressed table   cell red.

protected void right(int row, int column)

Turns the addressed table   cell green.

protected void wrong(int row, int column, String actual)

Turns the addressed table   cell red, and annotates it with the actuall value.

protected void ignore(int row, int column)

Turns the addressed cell   gray.

protected int getInt(int row, int column)

Converts the addressed cell   to an int, and returns it.

官网上的例子:http://www.fitnesse.org/FitNesse.UserGuide.WritingAcceptanceTests.FitFramework.TableFixture

Fitnesse FIT的使用的更多相关文章

  1. fitnesse 中各类fit fixture的python实现

    虽然网上都说slim效率很高,无奈找不到支持python的方法,继续用pyfit 1 Column Fixture 特点:行表格展现形式,一条测试用例对应一行数据 Wiki !define COMMA ...

  2. working with fitnesse wiki pages

    fitnesse提供一个简单易用的wiki创建一个web页面用于测试.测试页面有一个button,允许所有的测试在这个页面运行,因此任何人在任何时间都可以去这个页面点击这个按钮,查看测试是否通过.fi ...

  3. 扩展Fitnesse的ScriptTable:支持if-then

    Fitnesse的ScriptTable只能顺序执行所有行,本博文介绍如何让ScriptTable支持if-then,来条件执行一行. 首先普及一下概念,什么是Fitnesse,听一听.NET版Cuc ...

  4. Fitnesse+RestFixture:Web服务回归测试利器

    RestFixture是Fitness的一个测试REST服务的插件,用于调用标准的http GET/POST等请求方法,并可以用XPath语法和Javascript语法检验http响应.本文介绍安装运 ...

  5. 介绍并扩展Fitnesse的测试模块化机制:ScenarioTable

    摘要:在验收测试框架Fitneese中,使用Scenario可以把最常用的测试步骤封装起来,从而达到模块化定义Fitnesse测试用例的能力.但Scenario仅限于封装Script测试步骤,Scri ...

  6. 利用fitnesse实现api接口自动化测试

    上午在园子里乱逛,看了不少小伙伴们分享的接口测试方面的知识,仔细想想,我做接口测试也有几个年头了,大家所叙述到的一些经验或多或少,我也曾遇到过,突然意识到知识的点滴积累是多么的重要,我记得我最早接触接 ...

  7. Fitnesse使用系列二

    决策表 Fitnesse中提供了好几种表格样式,前面说了.表格是运行測试的关键.从字面看.表格描写叙述的是測试用例.从运行角度看,表格为后端的代码(fitnesse里称作fixture)提供了包名.类 ...

  8. fitnesse - 框架介绍

    fitnesse - 框架介绍 2017-09-29 目录: 1 fitnesse是什么?2 框架介绍3 与junit.testng比较,fitnesse教其他框架有什么优势 1 fitnesse是什 ...

  9. [原创]Fitnesse测试工具介绍及安装

    1 Fitnesse简介 Fitnesse是一款开源的验收测试框架,完全有java语言编写完成,支持多语言软件产品的测试,包括(java,c,c++,python,php),在Fitnesse框架中, ...

随机推荐

  1. Python 39 数据库的数据类型

    一:整型 为什么需要 数据分类? 1.为了描述事物更加准确 2.描述起来更方便 3.节省内存空间 例:1 a 你     utf8 下 5个字节 1 a b c   unicode 6个字节 mysq ...

  2. 2015 多校赛 第五场 1010 (hdu 5352)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5352 看题看得心好累. 题目大意: 给出 n 个点,依次执行 m 次操作:输入“1 x”时,表示将与 ...

  3. 树莓派-基于raspivid实现拍视频

    经过上一篇<<树莓派-安装摄像头模块>>之后 想要用摄像头模块拍一段视频的话,可以从命令行运行 raspivid 工具.下面这句命令会按照默认配置(长度5秒,分辨率1920x1 ...

  4. 常用MIME类型(Flv,Mp4的mime类型设置)

    也许你会在纳闷,为什么我上传了flv或MP4文件到服务器,可输入正确地址通过http协议来访问总是出现“无法找到该页”的404错误呢?这就表明mp4格式文件是服务器无法识别的,其实,这是没有在iis中 ...

  5. Linux安装java jdk、mysql、tomcat

    安装javajdk 1.8 检查是否安装 rpm -qa | grep jdk rpm方式安装 下载java1.8 jdk http://download.oracle.com/otn-pub/jav ...

  6. Android布局需要知道的基础知识

    eclipse配置环境变量: 1.在 eclipse 中的 Window --> preferences  --> Android(安装了ADT的前提下才能看到Android) --> ...

  7. telerik:RadAsyncUpload 使用 时不执行上传事件的解决办法AsyncUpload1_FileUploaded(object sender, FileUploadedEventArgs e)

    一般是因为web.config没有配置的原因! 只要在<handlers>下加上 <add name="Telerik.Web.UI.WebResource" v ...

  8. 经典实用SQL Server语句大全总结(一)

    简要介绍基础语句:1.说明:创建数据库CREATE DATABASE database-name2.说明:删除数据库drop database dbname3.说明:备份sql server--- 创 ...

  9. 《计算机图形学基础(OpenGL版)》使用院校(更新)

    从清华大学出版社责任编辑处获悉,很多高等院校选用了我们这本教材,读者反应不错! 另外,编辑提供了一份详细的使用院校名单如下: 河南科技学院 中原工学院 河北工程大学 防空兵学院 伊犁师院电信学院 吉林 ...

  10. 微信小程序跳转以及跳转的坑

    一.首先小程序的跳转方法有一下几种 js控制跳转 // 保留当前页面,跳转到应用内的某个页面 wx.navigateTo({ url: '../blueberry/blueberry' }); // ...