在被测系统上调用方法

Calling methods on System Under Test

使用 DoFixture 时,我可以将域对象设置为 System Under Test,这样我就可以调用该对象的方法,而不是 fixture 本身。

不幸的是,如果这样的方法需要多个参数,我必须用空单元格分隔这些参数,否则 fitnesse/fitSharp 使用 odd/even 单元格来构建方法名称。我可以看到这如何使我的测试更像简单的英语,但仅仅为了满足测试框架要求而开始重命名域对象方法并不可行。

例如,假设我要调用方法 Entry AddEntry(string name, string description) 并将结果存储为符号 e1。如果我尝试以下 table:

|name|e1|add entry|sample name|sample description|

它将尝试找到名为 AddEntrySampleDescription 的方法并向其传递一个参数 "sample name".

我可以

|name|e1|add|sample name|entry|sample description|

但它看起来不对。

所以,我最后做的是(注意参数之间额外的空单元格)

|name|e1|add entry|sample name||sample description|

它可以满足我的要求,并且不像选项 #2 那样丑陋,但它仍然看起来像是 hack。我是否遗漏了什么或者实际上是 在领域对象上调用方法的方法?

您可以在参数之间添加空单元格 - 这是一种广泛使用的技术。或者你可以使用 SequenceFixture:

http://fitnesse.org/FitNesse.UserGuide.FixtureGallery.FitLibraryFixtures.SequenceFixture

SequenceFixture is very similar to DoFixture and has almost the same features — in fact the only difference between those two is the naming convention for methods. Instead of using odd cells to construct a method name, SequenceFixture takes the first cell in each row as the method name, and all other cells as arguments