2016-12-02 53 views

回答

0

我可以去爲下面的方法解決此問題:

  1. 插入一個正則表達式提取的採樣那裏有機會得到意想不到的反應(這是目前在全球的斷言和因其中採樣器失敗)。

  2. 使用BeanShell PostProcessor和下面的代碼來覆蓋響應。因此不應將全局斷言應用於實際響應。

    import org.apache.jmeter.assertions.AssertionResult; 
    
    //Exception_RE is the Refernce Name for the regular exception extractor for Exception. 
    if(${__javaScript(vars.get('Exception_RE_matchNr')>=1,)}) { 
    
    String DefaultResponse = "My Test Response on Exception"; 
    
    //To over-write the sampler response with the our own response message when we encounter the Exception which is there in the global assertion. 
    prev.setResponseData(DefaultResponse); 
    
    
    prev.setResponseOK(); 
    
    } 
    
+0

您可以在您的文章有突出的代碼,按Ctrl + K格式化你的代碼。這使得代碼更易於閱讀。謝謝! – Alex

相關問題