asserttest.groovy
来自「大名鼎鼎的java动态脚本语言。已经通过了sun的认证」· GROOVY 代码 · 共 44 行
GROOVY
44 行
class AssertTest extends GroovyTestCase { void testAssert() { def x = null assert x == null assert x != "abc" assert x != "foo" x = "abc" assert x != "foo" assert x != null assert x != "def" assert x == "abc" assert x.equals("abc") assert !x.equals("def") assert !false assert !(1==2) assert !(1>3) assert !(1!=1) } void testAssertFail() { def x = 1234 def runCode = false try { runCode = true assert x == 5 fail("Should have thrown an exception") } catch (AssertionError e) { //msg = "Expression: (x == 5). Values: x = 1234" //assert e.getMessage() == msg //assert e.message == msg } assert runCode, "has not ran the try / catch block code" }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?