Thank you for reply. I created a BeanShell PreProcessor on testplan level that worked well. The other suggestion did not work -- the counter is not incremented, ie is always 1.
-------------------------------------------- On Wed, 7/30/14, sebb wrote: Subject: Re: Config Element:Counter based on Thread/User number? To: "JMeter Users List" <[email protected]> Date: Wednesday, July 30, 2014, 6:58 PM On 30 July 2014 22:06, rx wrote: > Hello, > New to JMETER , and have a question regarding Config Element->Counter. > > In my thread group, my first element is a Counter. I want to > use this counter to construct a logon id, where logon ids are > user0001, user0002, user0003 etc. When loop count > 1, > the logon id will be the same for each loop of that user. > > I expected that Counter would always equal __threadNum, such that > when __threadNum=2, Counter=2 as well. > > Instead, Counter is being incremented with each run of the > thread group. > > As a test, I created a user parameter: threadrun=${__threadNum}${__counter(true)} > The values when I run the test using Number of threads=2 and Loop Count=2 are: > > Counter = 0001 > threadrun = 11 > > Counter = 0002 > threadrun = 21 > > Counter = 0003 (I want this to be 0001) > threadrun = 12 (correct!) > > Counter = 0004 (I want this to be 0002) > threadrun = 22 (correct!) > > 1. How can I get Counter to match thread number? Have you tried: Start = ${__threadNum} Increment = 0 > 2. If that is not possible, how can I use __threadNum to construct my logon id. > __threadNum value is consistently correct, but it does not have the leading > zeros that I need. Use one of the scripting functions (jexl, javascript, beanshell) or scripting test elements to convert the threadNum string to a number and then use a format to add the leading zeroes. > I hope my post is clear, and I thank you for help in advance. --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
