I need to pass an object (my own business object) between two tables in one page. The value is got from the getter call in one fixture and then should be used as field in another fixture (both ColumnFixtures). Please note that the object to be passed is neither primitive nor String and the conversion is not that simple. Is it even possible? If so, then how?
Supposing you have two column fixture tables such as:
|TableOne |
|inputOne|outputOne()|
|7 |14 |
and
|TableTwo |
|inputTwo|outputTwo()|
|6 |20 |
then in the corresponding code you can store the object you wish to pass in a static variable (I'm using an int here but any type will work):
public class TableOne extends fit.ColumnFixture {
public static int result;
public int inputOne;
public int outputOne() {
result = inputOne * 2;
return result;
}
}
public class TableTwo extends fit.ColumnFixture {
public int inputTwo;
public int outputTwo() {
return TableOne.result + inputTwo;
}
}
Instead of using ColumnFixtures, however, I recommend that you look into Rick Mugridge's fitlibrary (in particular DoFixture) which allows fixtures to communicate in a more elegant way.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With