Difference between revisions of "Using Groovy in Testing"
From CitconWiki
Jump to navigationJump to searchLine 5: | Line 5: | ||
* You can use GroovyConsole or the interactive shell (groovysh) to try things out live | * You can use GroovyConsole or the interactive shell (groovysh) to try things out live | ||
* JUnit 3.8 built-in | * JUnit 3.8 built-in | ||
− | * Powerful assertion capability built-in to Groovy: (though for JUnit4 assertions, you need to use static imports) | + | * Powerful assertion capability built-in to Groovy\: (though for JUnit4 assertions, you need to use static imports) |
* JUnit 4 support including Parameterized tests and Theories [http://groovy.codehaus.org/Using+JUnit+4+with+Groovy Groovy Doco] | * JUnit 4 support including Parameterized tests and Theories [http://groovy.codehaus.org/Using+JUnit+4+with+Groovy Groovy Doco] | ||
* TestNG support | * TestNG support |
Revision as of 21:17, 1 July 2008
The bulk of the session introduced the Groovy language.
Benefits of using Groovy for writing developer tests were summarised as:
- Test code is shorter and sweeter (than Java)
- You can use GroovyConsole or the interactive shell (groovysh) to try things out live
- JUnit 3.8 built-in
- Powerful assertion capability built-in to Groovy\: (though for JUnit4 assertions, you need to use static imports)
- JUnit 4 support including Parameterized tests and Theories Groovy Doco
- TestNG support
- Full Java library support
- Built-in support making it easy to parse XML and access databases for data-driven tests
- Groovy's built in mocking is easy to use (but often you can get by with Closures, maps or expandos)
- Groovy is great for creating testing DSLs
- Groovy's fun!!
To use as a JUnit test, the simplest way is to extend GroovyTestCase. With the Groovy plugins installed, you can use Groovy JUnits in the same way as Java JUnits.