2017-04-19 134 views
0

我有一個執行一次簡單操作的JMeter測試計劃。當我將測試上傳到BlazeMeter時,我可以選擇我想要的線程組數量並運行測試。從設置線程組(jmeter)獲取線程組中的線程數(通過BlazeMeter定義)

我遇到的問題是我的測試設置需要知道線程組將具有多少個線程。爲了讓事情更清晰,這裏是測試計劃的簡單表示:

setUp Thread Group 
    needs to know the number of threads in the below thread group 
Thread Group 
    The number of threads for this thread group is determined via BlazeMeter test configuration 

在非設置線程組,我可以動態地獲得通過BlazeMeter分配的線程數,但我找不到任何方式從設置線程組中獲取此號碼。

任何想法?

回答

0

您可以使用以下Groovy代碼做到這一點:

def numberOfThreads = ctx.getThreadGroup().getNumThreads() 

演示:

JMeter get number of threads in thread group

的方法是環境無關的,所以你可以在任何地方使用它。它可能會更得心應手__groovy() function這樣的:${__groovy(ctx.getThreadGroup().getNumThreads(),)}

Groovy Function Number of Threads

Groovy Is the New Black文章的詳細信息,在JMeter的測試中使用Groovy腳本。

+0

這將返回安裝線程組中的線程數。我想要非安裝線程組中的線程數。 – Shawn

+1

'props.get(「blazemeter.test.threads」)' –

+0

您的評論回答我的問題,所以我會將您的答案標記爲已接受。如果你將評論編輯成你的答案,也許最好。 – Shawn

相關問題