0
assert !destinationDirectory: "Destination directory is required to create an archive"
這是否意味着如果destinationDirectory爲null,它旁邊的消息應該返回AssertionError?下面的陳述是什麼意思?
assert !destinationDirectory: "Destination directory is required to create an archive"
這是否意味着如果destinationDirectory爲null,它旁邊的消息應該返回AssertionError?下面的陳述是什麼意思?
是的。你可以通過簡單的運行測試來判斷。運行此:
assert false
你得到:
Assertion failed:
assert false
at org.codehaus.groovy.runtime.InvokerHelper.assertFailed(InvokerHelper.java:386)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.assertFailed(ScriptBytecodeAdapter.java:658)
at ConsoleScript5.run(ConsoleScript5:1)
....
然而,這樣的:
assert false: "This is false!"
給出:
java.lang.AssertionError: This is false!. Expression: false
at org.codehaus.groovy.runtime.InvokerHelper.assertFailed(InvokerHelper.java:388)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.assertFailed(ScriptBytecodeAdapter.java:658)
at ConsoleScript6.run(ConsoleScript6:1)
我找不到文件,驗證它,但我可能只是錯過了它。 It also looks like這種格式的工作原理相同:assert test, "message"
。
空或空字符串... –