简体   繁体   中英

FitNesse tests with objects as parameters

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.

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.

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|

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM