簡體   English   中英

JMeter:如何檢測測試已在 JSR223 (Java) 腳本中取消

[英]JMeter: How to detect the test has been cancelled in a JSR223 (Java) script

我編寫了一些在無限循環中運行的 Java 代碼。

我如何檢測到測試已經停止,所以我可以退出循環?

ThreadGroup class 中有running屬性,當測試停止時,該屬性設置為false ,因此您可以在循環中的某處檢查它,例如:

if (!ctx.getThreadGroup().running) {
    //do what you need here
}

Also be informed that if you choose java as the language in the JSR223 test element it's not real Java, it's Beanshell and since JMeter 3.1 you're supposed to use Groovy for scripting , moreover the above code won't even work and you will have顯式使用反射來讀取running的屬性值

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM