0

I am having trouble writing a FitNesse test for my application.

The test in itself is pretty simple.

We setup a loan, it has a few properies (Principal, Interest, Fees).

There is another object, Rules, which contains properties for paying back the loan.

The Loan class has a method called SplitLoan hat takes a Rules object, and will return a list of payments that need to be made.

A Payment would contain a total Amount, as well as individual amounts for Principal, Interest, and Fees.

How do I write this as a test in FitNesse?

I can't even get the call to happen because I don't know how I setup the Rules object that gets passed into the SplitLoan function.

CaffGeek
  • 21,856
  • 17
  • 100
  • 184

2 Answers2

0

I'm not positive this works in C#, but I know SLIM supports putting an object reference into a Symbol. You could use one fixture to build the Rules object, get a reference to it, then pass the symbol into another fixture that needs it as input.

http://fitnesse.org/FitNesse.SuiteAcceptanceTests.SuiteSlimTests.SlimSymbolCanHoldInstanceUsedAsParameter

Alternately, if you don't want to (or can't) get an object reference and store it in a symbol, you could have a fixture that builds the rules and stores them in a singleton with an identifier. Then you could pass that identifier in later fixtures and the fixture code could fetch the rules object from the singleton.

Dan Woodward
  • 2,559
  • 1
  • 16
  • 19
  • So, I'm confused. How are QA (or users!) supposed to be able to write these tests? – CaffGeek Aug 06 '13 at 18:47
  • You asked about doing a pretty technical thing, passing an object in. That is a little trickier than the a lot of the uses. I don't know anything about what the Rules object looks like, so it's hard to propose a fixture. But ideally the fixture that builds the rules has a human friendly fixture to define the rules. Then the test author does a "|$rulesObject=|get rules object|. This is then passed into your other fixture. – Dan Woodward Aug 06 '13 at 19:18
0

Does something like this do what you want? This is a fitSharp test.

|name|myrules|with|new|rules|

|with|myrules|
|set|myproperty|123|

|with|new|loan|
|set|principal|1000|
|set|interest|5|

|split loan|<<myrules|
|total|interest|principal|fees|
|100|80|5|15|
|100|78|7|15|
Mike Stockdale
  • 5,256
  • 3
  • 29
  • 33