From: Adam S. <ada...@ja...> - 2006-02-24 13:41:55
|
Hi Sebastian! Sebastian Simon wrote: > Is there any way i could use input from an excel for an array or > Collection Property of my Junit Test? > For example i have a Test with a property > > private int[] myIntArray; > > and i want to test the contents of the array within the testmethod. > How could i fill this form excel? Is there any way? Good question! The short answer is: right now, no, not directly to int[]. Please file an enhancement request in our bugtracker: http://jira.ddsteps.org and we will get on it! We use Spring and it Property Editors to do conversions from a String (the data in the Excel cell) to your target property. Sadly, there is no property editor for int[] in the Spring Framework - but there is one for String[]. Using Spring, you can easily add new property editors in your Spring context file, thereby supporting new conversions. I've been thinking about adding such capabilities to DDSteps too, so that you could have written your own converter. I see two possible work-arounds: 1) Use the String[] and convert strings to int:s in your code. Just comma separate the ints, and they will be chopped up into a string array. 2) Inject int:s one-by-one using one int per column: myArray[0] | myArray[1] and so on If you go for 2) then you should have a setter like this: setMyArray(int index, int value) that will resize the array to fit the data. I hope I was of some help to you? Regards /Adam Skogman, DDSteps Lead --- Jayway AB, www.jayway.se |