2012-02-20 7 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 
     . . . 

당신도 할 수있다 생각 HTTP 요청에 첨부 된 BSF 또는 BeanShell PostProcessor를 사용하여 IF를 사용하는 번거로운 구성 대신 txtFound 속성을 TRUE로 설정할 수 있습니다.

0

아니요, 런타임에 사용자 정의 변수에 값을 할당 할 수 있습니다. BeanShell PreProcessor를 사용하는 경우 vars.put("variablename", "variablevalue");