Jmeter : How to increment a value inside the reque

2019-06-27 12:11发布

问题:

I have a sample request like a bellow

{
  "schema": "urn:com.xyx9723.syodhnc:bulk.v1",
  "version": "7-06-26201",
  "msg": [
    {
      "topic": "tags/kdhud/${ID}/sadknnf",
      "ids": [
        {
          "_time": "2107-09-09 13:13:12",
          "id": "TID-2153656--00089312121"
        },
        {
          "_time": "2107-09-09 13:13:12",
          "id": "TID-2153656-00089312122"
        },
        {
          "_time": "2107-09-09 13:13:12",
          "id": "TID-2153656-00089312123"
        },
        {
          "_time": "2107-09-09 13:13:12",
          "id": "TID-2153656-00089312124"
        }
      ]
    }
  ]
}

When it comes to real test I have to send request with 100 IDS with increment values like (TID-2153656--00089312121, TID-2153656--00089312122, TID-2153656--00089312123 .... etc)

How to give incremental value in the request while sending a request in JMeter.

回答1:

Initialize somewhere variable id and then use it inside request several times, it will increase value with every occur:

${__intSum(${id},1,id)}


回答2:

Use Counter. Starts wìth 00089312121 Increment by 1 save in Reference Name cnt and Number Format 00000000

Inside your request call it with prefix:

  TID-2153656-${cnt}