天天看點

怎樣讓xml檔案的屬性值随機生成

怎樣讓xml檔案的屬性值随機生成

如:<request><jabber type="raw" ack="no_ack" data="&lt;message id='a98d8bed-ac21-4851-a8b3-6e4bd6523174' to='[email protected]' ><//request> id為随機值,而不是固定值

解答:

 首先dtd檔案裡要有random屬性

然後設定random="true"

如 <thinktime min="2" max="10" random="true"></thinktime> 這時 thinktime的取值為2-10之間

If you want to use a fixed seed for the random generator, you can use the seed option, like this (by default, tsung will

use the current time to set the seed, therefore random numbers should be different for every test)

如果你想使用一個固定的種子随機發生器,你可以使用種子标簽option,tsung使用目前時間,設定種子,這樣随機數每次都不一樣 <option name="seed" value="42"/>

搞定

前提條件,解析此xml的工具或軟體得支援random關鍵字,并對其進行随機政策處理。