使用FIT 进行确认测试.doc_第1页
使用FIT 进行确认测试.doc_第2页
使用FIT 进行确认测试.doc_第3页
使用FIT 进行确认测试.doc_第4页
使用FIT 进行确认测试.doc_第5页
已阅读5页,还剩9页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

使用FIT框架进行确认测试中国软件评测中心 陈 兵FIT(Framework for Integrated Tests) 是一种通用的开放框架,是由由Ward Cunningham开发的,可以帮助我们进行自动化的确认测试。自动化测试是轻型开发模式(XP、Crystal等)测试活动的另一个优秀思路也是采取轻型开发模式的必要条件之一。在只有测试实现了自动化,回归测试才能实现,重构(采取轻型开发模式另外的一个必要条件)才能够贯彻,而迭代也才能够进行。FIT利用JUnit并扩展了JUnit的测试功能。长期以来,在软件开发中我们一直关心着两个主要问题:第一,业务如何通过应用程序与其所需内容通信;第二,工程师如何验证他们是否正在构建满足业务需要的正确软件。多年来,为了解决这些关心的问题,已探索了许多方法和框架,但直到出现 Framework for Integrated Tests (FIT) 以后,才找到了解决这些问题的简便而直观的方法。使用FIT我们可以编写出可以自动运行的确认测试用例,可以用来确认我们所开发出来的软件是否满足了用户所需的功能,可以作为持续构建过程的一部分来确保所构建出来的版本是正确的。但是,FIT还有另外一个更为重要的功能,那就是在软件开发中增强协作,尤其是开发团队和客户、领域专家之间的协作。这种协作可以有效地降低软件开发中的不必要的复杂性,加速反馈,并确保最大程度地为客户提供最高的价值。l FIT如何工作简单来讲,FIT就是一个软件,它能够读取HTML文件中的表格(这些表格可以通过MicroSoft Word或者Excel产生)。针对每个表格,都会由一个程序员编写的fixture(装置)来解释。该fixture会驱动“被测系统 (SUTSystem Under Test)”来对表格中给出的测试用例进行检验。Fixture充当Fit表格和要测试系统间的媒介,起协调作用,完成表格中给出的测试。FIT中提供了好几种类型的Fixture,它们分别用于处理不同的情形。Fixture的形式有3种:n ColumnFixture(对应于“列”表),“列”表的形式如下图所示:CalculateScholarshipScoreScholarship()1000019990200050020505002100100022001500230020002350200024002500n RowFixture(对应于“行”表),“行”表的形式如下图所示:DiscountGroupOrderedListorderfuture valuemax owingmin purchasediscount percent 1low0.000.0002low0.002000.0033medium500.00600.0034medium0.00500.0055high2000.002000.0010n ActionFixture,表明以表格给出的测试用例的一系列的操作步骤。见表1。表1fit.ActionFixturestartcstc.example.coffeemaker.AddInventoryenterunits coffee 3enterunits milk 5enterunits sugar 6enterunits chocolate 7checkcoffee inventory 18checkmilk inventory 20checksugar inventory 21checkchocolate inventory 22在表1中,第1列给出了执行的命令,这里共有3个命令,但是其它的命令可以根据实际情况在ActionFixture.的子类中进行创建。上述的3个命令是:Start:与该Fixture相关联的类的名称Enter:该类的一个方法(带有一个变量)Check:该类的一个方法的返回值(不带变量)为该表格创建一个ActionFixture类如下:package cstc.example.coffeemaker;import fit.ActionFixture;public class AddInventory extends ActionFixture private CoffeeMaker cm = new CoffeeMaker(); private Inventory i = cm.checkInventory();public void unitsCoffee(int coffee) cm.addInventory(coffee,0,0,0); public void unitsMilk(int milk) cm.addInventory(0,milk,0,0); public void unitsSugar(int sugar) cm.addInventory(0,0,sugar,0); public void unitsChocolate(int chocolate) cm.addInventory(0,0,0,chocolate); public int coffeeInventory() return i.getCoffee(); public int milkInventory() return i.getMilk(); public int sugarInventory() return i.getSugar(); public int chocolateInventory() return i.getChocolate(); 此 fixture 将调用下面清单中显示的 SUT(被测对象) CoffeeMaker 类,然后调用该类上的相关方法。package cstc.example.ffeemaker;public class CoffeeMaker /* * Array of recipes in coffee maker */private Recipe recipeArray;/* Number of recipes in coffee maker */private final int NUM_RECIPES = 4;/* Array describing if the array is full */private boolean recipeFull;/* Inventory of the coffee maker */ private Inventory inventory; /* * Constructor for the coffee maker * */public CoffeeMaker() recipeArray = new RecipeNUM_RECIPES; recipeFull = new booleanNUM_RECIPES;for(int i = 0; i NUM_RECIPES; i+) recipeArrayi = new Recipe(); recipeFulli = false;inventory = new Inventory();/* * Returns true if a recipe is successfully added to the * coffee maker * param r * return boolean */public boolean addRecipe(Recipe r) boolean canAddRecipe = true; /Check if the recipe already exists for(int i = 0; i NUM_RECIPES; i+) if(r.equals(recipeArrayi) canAddRecipe = false; /Check for an empty recipe, add recipe to first empty spot if(canAddRecipe) int emptySpot = -1; for(int i = 0; i NUM_RECIPES; i+) if(!recipeFulli) emptySpot = i; canAddRecipe = true; if(emptySpot != -1) recipeArrayemptySpot = r; recipeFullemptySpot = true; else canAddRecipe = false; return canAddRecipe; /* * Returns true if the recipe was deleted from the * coffee maker * param r * return boolean */ public boolean deleteRecipe(Recipe r) boolean canDeleteRecipe = false; if(r != null) for(int i = 0; i NUM_RECIPES; i+) if(r.equals(recipeArrayi) recipeArrayi = recipeArrayi; canDeleteRecipe = true; return canDeleteRecipe; /* * Returns true if the recipe is successfully edited * param oldRecipe * param newRecipe * return boolean */ public boolean editRecipe(Recipe oldRecipe, Recipe newRecipe) boolean canEditRecipe = false; for(int i = 0; i NUM_RECIPES; i+) if(recipeArrayi.getName() != null) if(newRecipe.equals(recipeArrayi) recipeArrayi = new Recipe(); if(addRecipe(newRecipe) canEditRecipe = true; else /Unreachable line of code canEditRecipe = false; return canEditRecipe; /* * Returns true if inventory was successfully added * param amtCoffee * param amtMilk * param amtSugar * param amtChocolate * return boolean */ public boolean addInventory(int amtCoffee, int amtMilk, int amtSugar, int amtChocolate) boolean canAddInventory = true; if(amtCoffee 0 | amtMilk 0 | amtChocolate 0) canAddInventory = false; else inventory.setCoffee(inventory.getCoffee() + amtCoffee); inventory.setMilk(inventory.getMilk() + amtMilk); inventory.setSugar(inventory.getSugar() + amtSugar); inventory.setChocolate(inventory.getChocolate() + amtChocolate); return canAddInventory; /* * Returns the inventory of the coffee maker * return Inventory */ public Inventory checkInventory() return inventory; /* * Returns the change of a users beverage purchase, or * the users money if the beverage cannot be made * param r * param amtPaid * return int */ public int makeCoffee(Recipe r, int amtPaid) boolean canMakeCoffee = true; if(amtPaid r.getPrice() canMakeCoffee = false; if(!inventory.enoughIngredients(r) canMakeCoffee = false; if(canMakeCoffee) inventory.setCoffee(inventory.getCoffee() + r.getAmtCoffee(); inventory.setMilk(inventory.getMilk() - r.getAmtMilk(); inventory.setSugar(inventory.getSugar() - r.getAmtSugar(); inventory.setChocolate(inventory.getChocolate() - r.getAmtChocolate(); return amtPaid - r.getPrice(); else return amtPaid; /* * Returns an array of all the recipes * return Recipe */ public Recipe getRecipes() return recipeArray; /* * Returns the Recipe associated with the given name * param name * return Recipe */public Recipe getRecipeForName(String name) Recipe r = null;for(int i = 0; i Software Updates Find and Install。得到如下图所示的wizard。(2) 选择Search for new features to install,按Next按钮。(3) 按New Remote Site.添加一个remote site,见下图。(4) 在Name输入框中输入Fit Plug-in(名字可以任取),在URL输入框中输入/update/,按OK按钮。(5) 按Finish按钮。(6) 后面的操作步骤按照常规的eclipse“Installing Plugin with the update manager”的操作步骤进行操作即可完成Fit的

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论