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将抛出异常(ⅰ具有该行为不同的测试)。