如何声明expectedException以便只传递异常和子类?目前我正在使用expectedException: Any.
细节.
我有一个像这样调用的测试实用程序方法,
assertExceptionThrown("En-passant should be rejected when the previous move was not a double advance", classOf[UnreachablePositionException] ) {
e.rejectIllegalMove(EnPassant("e5", "d6"))
}
Run Code Online (Sandbox Code Playgroud)
第一个参数列表的第二个参数是classOf [SomeException].这是测试方法的签名,
// TODO: Restrict expectedException to Exception or subclass
def assertExceptionThrown(assertion: String, expectedException: Any)(b: => Unit) {
Run Code Online (Sandbox Code Playgroud)
我的问题是如何声明expectedException,以便只传递异常和子类?目前我正在使用expectedException:Any.
测试特征的完整来源在这里, https://github.com/janekdb/stair-chess/blob/master/src/test/Test.scala
这是我目前不能令人满意的解决方案,在传递给超类构造函数之前操纵传递给子类构造函数的值的问题,
class MissingItemsException(items: Set[String], itemsCategory: String)
extends RuntimeException(MissingItemsException.makeMessage(items, itemsCategory))
private object MissingItemsException {
private def makeMessage(items: Set[String], itemsCategory: String): String = {
/* Format set as ['?','?','?'] */
val Items = items mkString ("['", "','", "']")
"the following items %s were missing from '%s'" format (items, itemsCategory)
}
}
Run Code Online (Sandbox Code Playgroud)
是否有一种方法可以分解转换,以便转换代码保持接近使用点,同时保持代码清晰?
根据Nodes() 函数返回关系?Neo4j 浏览器中有一个 AUTO-COMPLETE 开关。我正在使用没有这个的 3.2.0。是否有等效的 UI 元素?