2012-02-20 35 views
0

私はJmeter(2.5.1)でテストケースを持っています。
私は基本的に、変数を定義して、whileループでその値を変更する必要があります。JMeterループ変数

isQuest = true; 
while(${isQuest}){ 
    Http Sampler 
     Reg Exp Extractor -> set the isQuest based on the result 
} 

のJMeterは最初に一旦メモリにユーザー定義の変数をロードしているので、それは私が別のものを割り当てることはできません。値をメモリ内の変数に設定します。

この問題を解決する最善の方法は何ですか?

+0

[回答がありますか?](http://stackoverflow.com/faq#howtoask) –

答えて

1

あなたが代わりにjmeter functionsまたはBeanShellのコードを介してアクセス変数のJMeterのプロパティを使用することがあります。

${__P(whileCondition,)} 
${__setProperty(whileCondition,TRUE,)} 
${__BeanShell(props.get("whileCondition")} 
${__BeanShell(props.set("whileCondition")} 

あなたは次のような構成のようなものを使用しようとする場合があります。

 
Thread Group 
    HTTP Request 
    //set-found-condition 
    ${__setProperty(txtFound,FALSE,)} 
    While Controller 
    // invert value in condition - will be executed while txtFound == FALSE 
    Condition = ${__BeanShell(!props.get("txtFound")} 
     . . . 
     [execute your test logic here] 
     . . . 
     YOUR HTTP Request 
      Response Assertion 
      // set your text assertion here 
      // this will results in ${JMeterThread.last_sample_ok} = TRUE if text found 
     IF Controller --FOUND 
     // if text found set separate variable or property - e.g. ${txtFound} - into TRUE 
     Condition = ${JMeterThread.last_sample_ok} 
      HTTP Request 
      //set-found-condition 
      ${__setProperty(txtFound,TRUE,)} // this will be inverted to FALSE in the next WHILE cycle's condition, WHILE cycle will be exited 
     . . . 

私はあなたにもかもしれないと思いますYOUR HTTP Requestに添付されているBSFまたはBeanShell PostProcessorを使用して、IFを使った煩雑な構築ではなく、txtFoundプロパティをTRUEに設定します。

0

いいえ、実行時にユーザー定義変数に値を割り当てることができます。 BeanShell PreProcessorを使用している場合、vars.put("variablename", "variablevalue");

関連する問題