acceptancetestingwithfitnesse内容摘要:

e fixture class should extend and declare public fields and methods to match the second table row. import extends ColumnFixture 24 It is intended for workflowstyle tests that are not repetitive. !|ActionFixture| |start|ActionFixtureTest| |enter|firstPart|Hello| |enter|secondPart|World| |press|join| |check|together|Hello, World| public class ActionFixtureTest extends { private String first, second, both。 public void firstPart(String s){ first=s。 } public void secondPart(String s){ second=s。 } public void join(){ both=first+ , +second。 } public String together(){ return both。 } } ActionFixture All rows after the first begin with a mand cell, followed by mand arguments in the remaining cells. Possible mands are: start — it starts the test by taking the class name for the actual fixture to automate check — it executes a method and verifies its value. press — it executes a void method without testing anything. enter — it executes a method and passes an argument to it. import。 extends ActionFixture 25 It tests dynamic lists of objects. It will pare the expected list (FitNesse table) with the actual result (from fixture code) and report any additional or missing items. !|RowFixtureTest| |name|post code| |John Smith|SW4 66Z| |Michael Jordan|NE1 8AT| import。 import。 public class RowFixtureTest extends RowFixture{ public Class getTargetClass() { return。 } public Object[] query() throws Exception { return ()。 } } RowFixture Override: getTargetClass: returns the Type or Class object representing the type of objects in the array. query: returns the actual array of objects to be verified. The second row describes the properties or methods that you want to verify All rows after that describe expected objects in the array import extends RowFixture 26 It is useful for adding a bunch of data to a database or for calling a function over and over again with different arguments. || |v| |1| |0| public class RowEntryExample extends RowEntryFixture{ public int v。 public void enterRow() throws Exception{ if (v == 0) throw new Exception(Oh, no! Zero!)。 } } RowEntryFixture • RowEntryFixture is an abstract class. You have to derive from it. • It derives from ColumnFixture and works just the same way it does. • You override the enterRow function to add your data to the database. The first row contains the field that we want to enter All rows after the first contain the data to be added import。 extends RowEntryFixture 27 An example: Sum Calculator public class MySum { public static int sum (int a, int b) { return a+b。 } } public class MyFixture extends ColumnFixture { int a,b。 public int sum () { return (a,b)。 } } A full demo: 28 An example: Football team Website  A sports magazine decides to add a new feature to its Website that will allow users to view top football teams based on their ratings.  An analyst and a developer get together to discuss the change requirements.  The oute of the discussion is: – a user story card that summarizes the change requirements – a set of acceptance tests – an excel file with sample data user story (change requirement) set of acceptance tests excel file with sample data 30 Test1: Table “verify the rating is calculated properly”  For a team, given the number of matches played, won, drawn, and lost, we need to verify that the ratings are calculated properly.  The first step is to express the logic using a Fit table.  The table created using Excel can be easily converted into a Fit table by just adding a fixture name and modifying the labels.  The Fit table on the right represents the first acceptance test case to verify the rating calculation.  Now that we have created the Fit table, we need to write the glue code that will bridge the test case to the system under test.。
阅读剩余 0%
本站所有文章资讯、展示的图片素材等内容均为注册用户上传(部分报媒/平媒内容转载自网络合作媒体),仅供学习参考。 用户通过本站上传、发布的任何内容的知识产权归属用户或原始著作权人所有。如有侵犯您的版权,请联系我们反馈本站将在三个工作日内改正。