2016-11-20 22 views
0

我試圖驗證兩個條件中最終阻止......像這樣我可以驗證scalatest內部的兩個條件最終阻止嗎?

eventually(timeout(Span(26, Seconds)), interval(Span(2, Seconds))) { 
     response = executeSomeFunction 
     response should be = (true) 
     if (response) { 
      something = responseResult.get 
      something should be >= (10) 
     } 
     } 

什麼找的是最終要滿足這兩個條件。首先它應該檢查響應是否爲真,然後當響應爲true時,它應該驗證if循環內部的條件。 我試圖執行這一點,但我得到錯誤信息

曖昧參考超載定義」引用排隊 ‘的反應應該是=(真)’

我不知道什麼,我試圖做甚至有可能最終裏面還是不。

回答

0

的問題是,你寫

response should be = (true) 

但實際上你想寫:

response shouldBe true 

你的情況,你做的response should be: ResultOfBeWordForAny[Boolean]分配的值true。不清楚您期望的轉換。

P.S.在eventually區塊外還寫response = executeSomeFunction,否則可能會執行多次。

P.P.S此外,你不需要eventual調用,如果你測試你的函數的結果,無論如何在範圍內。 eventually不是最佳實踐,當功能有一些你想測試的異步副作用時使用。