On Sun, 11 Nov 2001, Phil Tomson wrote: > >- a tool to combine lists of test data such that every pairwise combination > > of values is present. (That is, if A=[on, off] and B=[red, yellow, green], > > the result is [on, red], [on, yellow], etc. It gets more complicated if you > > have more variables and you want a minimal list.) > > > > This is sort of the idea I have for using Ruby Templates. > > Say you have a template file that you will use to generate testcases, > like: > > begin > A = #{width} > B = #{length} > C = #{depth} > end > > Now let's say you want to generate testcases with the following length for > width, length, depth: > > width = (0..10) > length = [5,7,9,11,42] > depth = (4..8) > > Then you could iterate through each of the ranges/arrays to create a > catesian product and plug the values in as you use the TemplateFile class. > (I don't have all the details here now, but it looks like you could use > the enumerable tools module to do something like: > > for width,length,depth product do > tf = TemplateFile.new("template",binding) > tf.transform #and you could write the resulting string to a file > #and call it a testcase > end > > This way you create one testcase template to generate multiple testcases. > I found this pretty useful for the type of testing I was doing. > I'm not sure this generating-text thing is good. IMHO, its often better to make things "first-class" in the language, ie. for Ruby make them objects that one can work with. As an example check out the hierarchy of test data generators in 'autotest'. See [ruby-talk:10855] and then http://www.ce.chalmers.se/~feldt/ruby/extensions/autotest/. Regards, Robert