jmeter-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Yiming Li <yiming...@umail.ucsb.edu>
Subject Re: a question regarding to JUnit Sampler string constructor
Date Sat, 16 Oct 2010 17:56:36 GMT
Thank sebb. I think now I know the reason why it didn't work.
I also notice that there is a Java Request Sampler, how are variables
resolved for it?
Can I define a Java Request Sampler instead of JUnit Sampler and send
${myId} to it?


On Sat, Oct 16, 2010 at 4:15 AM, sebb <sebbaz@gmail.com> wrote:
> On 16 October 2010 06:28, Yiming Li <yiming_li@umail.ucsb.edu> wrote:
>> Hi All,
>>       I am a newbie to jMeter, and I got this problem recently:
>>       I wanted to add a JUnit sampler, part of the unit test was to
>> print an id, and the id was passed in through the constructor, like
>> the following:
>>
>>       public class MyTest     {
>>
>>       private String id;
>>
>>       public MyTest(String id){
>>            this.id = id;
>>       }
>>
>>       @Test
>>       public void printId(){
>>            System.out.println(this.id);
>>       }
>>       ......
>>       }
>>
>>       To make it simple, I used the counter config to generate the
>> id, and I set the "Reference Name" of the counter as "myId". After
>> that I put ${myId} in the "Constructor String Label" field of the
>> JUnit Sampler and ran the test.
>>        To my surprise, the output was the literal string "${myId}",
>> which meant that the counter value was not replaced.
>>        Do you know what caused the problem? Any suggestions are appreciated!
>
> The test class instance is resolved at the very start of the test, so
> it's not possible to vary the constructor label at run time.
> Variable references do work if you define them on the Test Plan, but
> you cannot change them later.
>
>> Yiming
>>
>> --
>> Yiming
>> MS student of CS Department @UCSB
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>
>



-- 
Yiming
MS student of CS Department @UCSB

---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org


Mime
View raw message