Closed wagnerfrancisco closed 11 years ago
You also can add literal values, like this:
add("items", Arrays.asList("itemOne", "itemTwo"));
@douglasrodrigo I think that @wagnerfrancisco didn't mean this.
When we use has().of() we can only pass one template, I believe he wants to specify more than one template.
@wagnerfrancisco am I correct?
It's exactly that @nykolaslima ! Is it possible?
It's not possible.
But why you wanna do this?
If you wanna do this because you need different data, you can use functions to generate custom data.
Eg: add("email", regex("my regex to generate emails"); add("creationDate", instant("2 days ago"); add("age", random(17, 30, 45));
Using functions instead of "hard-coded" data maybe help you. This way you dont need to use two different tremplates and instead of this you can create a template that cover the 2 other templates.
Sent from my iPhone
On 28/06/2013, at 21:40, Wagner Francisco Mezaroba notifications@github.com wrote:
It's exactly that @nykolaslima ! Is it possible?
— Reply to this email directly or view it on GitHub.
Hi. Actually I'm testing an xml conversion, I'm creating an object that is going to be converted to xml. This object contains a list and I just would like to ensure this list is going to be properly converted.
I already had this object created without fixture-factory and now I'm justing refactoring the code. But thinking better, I really think in my case it's not necessary to have two different values in the list. Even if the objects are equal my test is going to be useful. I was just trying to get the same object I had before using fixture-factory.
Thanks!
But you can have different objects using the same template. To do this you need to use functions instead of hard coded values.
Just like my examples in the other comment.
Sent from my iPhone
On 28/06/2013, at 23:29, Wagner Francisco Mezaroba notifications@github.com wrote:
Hi. Actually I'm testing an xml conversion, I'm creating an object that is going to be converted to xml. This object contains a list and I just would like to ensure this list is going to be properly converted.
I already had this object created without fixture-factory and now I'm justing refactoring the code. But thinking better, I really think in my case it's not necessary to have two different values in the list. Even if the objects are equal my test is going to be useful. I was just trying to get the same object I had before using fixture-factory.
Thanks!
— Reply to this email directly or view it on GitHub.
@wagnerfrancisco can we close this?
@nykolaslima and @douglasrodrigo, thanks for your help.
Yes, feel free to close this.
Just started using this framework and I didn't realize how to create a list with different elements. I think this is not possible, right? Something like this:
add("items", has(2).of(Item.class, "itemOne", "itemTwo");