1
我必須測試一個無循環圖並總是檢查字符串是否不同不是非常有用(它會引發異常)。必須有更好的解決方案,但我無法想出它,而且我在specs2文檔中迷失了方向。 這是代碼的示例:Specs2 + Scalacheck使用不同的字符串生成元組
"BiDirectionalEdge" should {
"throw an Error for the wrong DirectedEdges" in prop {
(a :String, b :String, c :String, d :String) =>
val edge1 = createDirectedEdge(a, b, c)
val edge2 = createDirectedEdge(c, b, d)
new BiDirectionalEdge(edge1, edge2) must throwA[InvalidFormatException] or(a mustEqual d)
}
如果a和c都是一樣的,createDirectedEdge將拋出異常(ⅰ具有該行爲不同的測試)。