0

this question is very easystest-specific (but i don't know a better place to ask).

Is there a way to use parameters of type Array or List? Is there probably a separator character that could be used like this (excel table):

testMethod doubleList stringList 3.5,3.4,6.7 a,b,c

(the separator char is here ',')So that i get two paramters List doublelist and List stringList. At the moment i do this by hand: using all as String parameter and "split" them on ','. and then converting the single strings to desired type. Is there a "easier" way with easytest?

dermoritz
  • 12,519
  • 25
  • 97
  • 185
  • separate values by ',' -> does not work. easy test tries to convert 3.5,2.5 to one double. but it seems that list are supported: @Param(name = "amounts") final List expected.. does work at least for cells with one value. – dermoritz Mar 26 '13 at 15:20

2 Answers2

1

You simply use ':' as a delimiter and EasyTest splits up the string into a collection for you.

The javadoc of the @Param annotation in EasyTest says:

"If you want to pass a Collection type, then EasyTest framework provides the functionality to instantiate the Collection class for you and pass in the right generic parameter if possible. For eg. if you have a test method like this :

@Test
public void testArrayList(@Param(name="items") ArrayList<ItemId> items){
    Assert.assertNotNull(items);
    for(ItemId item : items){
        System.out.println("testArrayList : "+item);
    }
}

then all you have to do is : pass the list of itemIds as ":" separated list in the test data file(XML, CSV,Excel or custom), for eg: 23:56:908:666

and register an editor or converter for converting the String data to object. In case the generic type argument to the Collection is a standard Java type(Date, Character, Timestamp, Long, Interger, Float, Double etc) then you don't have to do anything and the framework will take care of converting the String data to the requested type."

supersmo
  • 61
  • 1
  • 3
0

EasyTest works on row basis (as per my knowledge). They have not given any provision for handling List of objects. I am using the same way. I feel it easier for primitive types but what about List of Objects..?

Jay
  • 651
  • 1
  • 6
  • 10