Logo QF-Test

Im Archiv der Mailingliste
wertvolle Antworten finden.

 

Gratis Testen  Download  Kaufen

Thomas Max, QF-Test Training und Support

Tipp für die Recherche in der Mailingliste: Volltextsuche (oben) verwenden.

Thomas Max,
Sr. Software Engineer & Trainer, QFS

2016 bis heute 2015 | 2014 | 2013 | 2012 | 2011 2010 2009 | 2008 | 2007

(ältere Archiveinträge vor 2007 nicht dargestellt, aber in der Suche enthalten)

Mailingliste - Einträge 2007


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [QF-Test] Arrays in QF-Test


  • Subject: Re: [QF-Test] Arrays in QF-Test
  • From: Gregor Schmid <Gregor.Schmid@?.de>
  • Date: 01 May 2007 20:48:48 +0200

Hi Adrian,

though you've now got a working solution, I think I should explain
things in a bit more detail lest people get some wrong ideas
here... :-)

In fact it only appears as if you can use an array as a QF-Test
variable. This is true only for simple arrays that can be represented
as a String that can be parsed into an array by the Jython
interpreter.

In fact, QF-Test only stores the plain String

'["apple","pear","banana","orange"]'

Each time you invoke ${jython:...$(array)...} this String is parsed by
the again Jython interpreter. It works fine this way for arrays of
simple types that can easily be represented as a String, but will not
work with arrays of objects.

As an alternative, you can store the array (in fact any kind of array
or any other Jython type!) in a global server-side Jython variable.
Just run the "Server script"

global array
array = ["apple","pear","banana","orange"]

Now you can use this as before in ${jython:...} with the difference
that no QF-Test variable is involved anymore, so instead of $(array)
you just use array. Thus

${jython:array[1]}

will expand to "pear" and

${jython:len(array)}

expands to 4.

This solution is cleaner and more aesthetically pleasing, but your
mileage may vary... :-)

Best regards,
    Greg


"Adrian Chamberlain \(BE/ETL\)" <adrian.chamberlain@?.com> writes:

> Thank you Greg.   Much appreciated.
>
> ${jython:len($(array))}  works perfectly.
>
>
>
> This means of course that a parameter value to a QF-Test procedure
> could be an array and the called procedure can use the above
> solution to identify how many elements are in that array. Same
> applies to return values from QF-Test procedures.
>
> Many thanks for your help.
>
> Kind Regards
>
> Adrian
>
> ________________________________
>
> From: Gregor Schmid [mailto:Gregor.Schmid@?.de]
> Sent: Tue 01/05/2007 18:05
> To: qftest-list@?.de
> Cc: Adrian Chamberlain (BE/ETL)
> Subject: Re: [QF-Test] Arrays in QF-Test
>
>
>
>
> Hi Adrian,
>
> simply try ${jython:len($(array))}, or, since there are no nested ']'
> characters, even simpler $[len($(array))].
>
> Best regards,
>     Greg
>
>
> "Adrian Chamberlain \(BE/ETL\)" <adrian.chamberlain@?.com> writes:
>
> > Following on from the previous archive entries entitled:
> > 'Re: [QF-Test] Help regarding reading values from Properties file'
> >
> > Set variable node [ 'array', ["apple","pear","banana","orange"] ]
> >
> > set variable node [ 'element1', ${jython:$(array)[0]} ]
> > set variable node [ 'element2', ${jython:$(array)[1]} ]
> > etc.
> >
> > Hence,
> > QF-Test variable 'element1' will equal 'apple'
> > and
> > QF-Test variable 'element2' will equal 'pear'
> > etc.
> >
> > At the risk of asking a silly question how does one get the length of this array
> > without resorting to an SUT or Server script.
> >
> > i.e. set variable node [ array_size, len($(array)[]) ]
> >
> > Can anyone point out what the correct syntax should be?
> >
> > Thank you in advance for any help offered.
> > Kind Regards
> > A.Chamberlain

--
Gregor Schmid                                Gregor.Schmid@?.de
Quality First Software GmbH                     http://www.qfs.de
Tulpenstr. 41                                Tel: +49 8171 919870
DE-82538 Geretsried                          Fax: +49 8171 919876
GF: Gregor Schmid, Karlheinz Kellerer          HRB München 140833



Videos Downloads Dokumentation Kaufen Gratis Testen