浅谈Fitnesse测试框架 (二)

上一篇 / 下一篇  2009-09-09 00:15:29 / 个人分类:API测试框架

  Fitnesee测试框架中有两个不同的测试方法,Slim和Fit。在工作中发现两者有不同的使用用途和方法。只有分析清楚了两者的区别和共同之处,才能选择出正确的测试方法来提高工作效率。
  Fitnesse的默认测试方法是Fit,要使用Slim进行测试的话,需要在测试Page中指定
  !define TEST_SYSTEM {slim} 我们可以把TEST_SYSTEM理解为系统变量。当然我们也可以用Define来定义一些用户自己的变量,这个就以后再写了。
  Fit方法会从Fitnesse得到传来的Html文件,解析后和Fixture关联来执行Case,而Slim直接从Fitnesse中得到Html中的内容,因此Slim更加的轻便,有更好的独立性。
  每一个测试类型都有自己对应的TestTable类型

  Slim的TestTable如下
 
Decision TableSupplies the inputs and outputs for decisions. This is similar to the Fit Column Fixture
Query TableSupplies the expected results of a query. This is similar to the Fit Row Fixture
Ordered query TableSupplies the expected results of a query. The rows are expected to be in order. This is similar to the Fit Row Fixture
Script. TableA series of actions and checks. Similar to Do Fixture.
Table TableWhatever you want it to be!
ImportAdd a path to the fixture search path.
CommentA table that does nothing.
Scenario TableA table that can be called from other tables.

  Fit的TestTable如下
ColumnFixtureThis is the style. you may end up using most: rows of data represent inputs and expected outputs.
RowFixtureThis is good for testing queries that should return an exact set of values (order-independently).
ActionFixtureThis style. allows you write a script. that emulates a series of events (such as controls manipulated on a user interface).
Comment TablesSometimes you want a tablular comment that is not executed as a test.
   两者有相似的几个TestTabel 如Decission Table对应ColumnFixture等等。

   Fit接受输入Null代表空指针,Blank代表空的字符串,而Slim不接受,因此对于Slim的输入,我们需要写一个Converter来进行转换。类似于

public String converter(String input)
   if(input.equals("null")
       return null;
   else if (input.equals("blank"))
       return "";

这样也就解决了转换的问题。

很晚了,睡觉去了,明天继续研究Fitnesse
 

TAG:

 

评分:0

我来说两句

Open Toolbar