i'm in a bit of a dilemma here and/or cant see other options at the moment
I know how to call a fixture method that stores an object and returns the object with predefined parameters
|$car=|create Test Car |
I know how to cal a fixture that uses setters and in that way, has flexible use of fields - no predefined parameters
!|Car Fixture |
|ContactEmailadres |ContactTelefoonnummer|
|klaasJanHotmail.com|0612345678 |
This last one comes close to the perfect scenario, however I want to store or return the object or at least one field (id) for later use in the test.
What i thought of so far and got stuck in
Use Symbol
getEnvironment().setSymbol("carID", car.getID()); //Dunno if this works because I was not succesful so far in calling it in the code after the script
Try to use setters and then method Haven't found a way to chain these methods, tried variants like below
!|Car Fixture | |
|ContactEmailadres |ContactTelefoonnummer|create Test Car |
|klaasJanHotmail.com|0612345678 |$car=
So basically flexible use of parameters and a return type is the goal and I guess the inexperience with the Fitnesse syntax is the issue in this!
Thanks in advance!
You can make the approach in your last table work (although I suspect you forgot to copy the last |
).
I guess you are using a 'dynamic decision table' in that case? I'm not a 100% sure it works out-of-the box like that, because I never use it like that. But I suspect you need to add a ?
to the create Test Car
column header, to indicate it is method whose value you want to retrieve instead of set.
I have implemented my own fixture that allows setting of symbols like that, so that does work ;-). And I know this works when the decision table is calling a scenario instead of a Java class directly.
I general I would recommend using a scenario with output parameters in a decision table. I'm sure that works out of the box and doesn't require anything complex in the fixtures. In columns where the name ends on a ?
you can either check a value against the value specified in the decision table, or assign it to a symbol. (The scenario approach also allows you to check whether the returned value meets your expected criteria before using it further on in a test.)