Created
February 13, 2011 11:12
-
-
Save miceno/824596 to your computer and use it in GitHub Desktop.
Groovy testing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class MyClass{ | |
| def myname | |
| } | |
| class TestCase{ | |
| TestCase(){ } | |
| def testNonEmptyTask(){ | |
| def f = new MyClass() | |
| def name = "miceno" | |
| println "processing $name" | |
| f.myname= name | |
| assert f.myname == name | |
| } | |
| def testNullTask(){ | |
| def f = new MyClass() | |
| def name = null | |
| println "processing $name" | |
| f.myname= name | |
| assert f.myname == name | |
| } | |
| } | |
| def t= new TestCase() | |
| // Invoke all the test* methods | |
| t.class.methods.findAll{ | |
| it.name.contains( 'test') | |
| }.each{ | |
| println "Testing ${it.name}"; | |
| t.invokeMethod( it.name, null) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment