La liste de diffusion est fermée depuis juillet 2022, mais sert toujours d'archive d'informations sur QF-Test.
Cependant, si vous souhaitez rester informé des nouveautés concernant QF-Test, vous pouvez simplement vous
abonner à la newsletter
our obtenir des informations à jour sur chaque version - y compris les versions mineures - vous pouvez
nous pouvez vous abonner au flux RSS ou nous suivre sur les médias sociaux.
Alternativement, QF-Test fournit également des informations sur la version elle-même.
Une autre source d'information est notre blog, qui contient des articles actuels sur des thèmes généraux, sur l'entreprise QFS et aussi divers "how-tos", veuillez vous
ABonner au Blog
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [QF-Test] Syntax question for IF statement using AND in QFTest
Hello Michael, thanks for your answer, which is quite to the point. However, there are some subtle details about the interaction between QF-Test and Jython to take into account, so here are some additional explanations: The $(...) variables are expanded first, then the whole expression is passed to the Jython interpreter. Thus, care must be taken in case those variables expand to strings instead of boolean or numeric values. Strings must be quoted or Jython will try to treat them as the names of Jython variables, which typically don't exist. For Rick's example this means: not $(ORFoundFlag) and "$(CurrentDateRangeSelector)" == "$(NBR_DATE_RANGES)" It gets even more difficult if the strings might be multi-line or contain special characters like backslash or double quotes in which case the expanded expression would no longer be valid Jython. In such a case - or in general as the safe alternative - one can use the method calls rc.lookup, rc.getBool and rc.getNum. These are expanded by the Jython interpreter, resulting in a string, boolean or number respectively, e.g. not rc.getBool("ORFoundFlag") and rc.lookup("CurrentDateRangeSelector") == rc.lookup("NBR_DATE_RANGES") Please note the different ways of quoting and bracketing in the two examples above. Best regards, Greg Michael Pruemm <eso@?.org> writes: > The IF-condition follows Python syntax. You can simply write: > > not $(ORFoundFlag) and $(CurrentDateRangeSelector) == $(NBR_DATE_RANGES) > > Note that the keywords "not", "and", "or" must be lowercase and that the comparison uses "==" to > test for equality. > > A technical description of this can be found in sections 5.9 Comparisons and 5.10 Boolean > Operations of the Python language reference: > > https://docs.python.org/2.6/reference/expressions.html#notin > > The link is to the oldest Python 2.x version still on the Python site. QF-Test uses Jython 2.5 > which is a bit older, but the language hasn't changed regarding theses expressions. > On 03.04.2015, at 19:19, Rick Brasche <Rick.Brasche@?.org> wrote: > > Hello All. > > This is probably a simple question for most of you but it’s driving me batty. > > I have an IF condition that runs off of 3 variables. > > One is a loop iteration count and the other is a max number of loops taken from a table. > > The other is a flag variable set by how the SUT responds. > > It starts the loop like this: > > Set variable: ORFoundFlag=False > > If data is found, it will > > Set variable:ORFoundFlag=True > > So at the end of each loop, I have > > IF > > $(ORFoundFlag) == False AND $(CurrentDateRangeSelector) = $(NBR_DATE_RANGES) > > Which gives me a “this is not a valid test” error. > > Adding quotes to the False does nothing either. Nor does using one = > > I’m hoping extra experienced eyeballs can spot the problem right away. > > Thanks in advance! > > Rick Brasche, > > Information Systems Business Process and Data Entry Automation > > Home of Application Testing > > ------------------------------------------------------------------------------------------------------------------------------ > > “The difficult we do immediately, the impossible just takes a bit longer.” – US Navy SeaBees. > > “If it ain’t broke, you’re not trying hard enough.” – “the Red Green Show” > > NOTICE: This email message and/or its attachments may contain > information that is confidential or restricted. It is intended only for > the individuals named as recipients in the message. If you are NOT an > authorized recipient, you are prohibited from using, delivering, > distributing, printing, copying, or disclosing the message or content to > others and must delete the message from your computer. If you have > received this message in error, please notify the sender by return > email. > -- Gregor Schmid E: gregor.schmid@?.de T: +49 (0)8171 38648-11 F: +49 (0)8171 38648-16 Quality First Software GmbH | www.qfs.de Tulpenstr. 41 | 82538 Geretsried | Germany GF Gregor Schmid, Karlheinz Kellerer HRB München 140833