Java Reference
In-Depth Information
Listing 2.9. GetGameDataTests.groovy : a JUnit 4 test case
This is a standard JUnit 4 test case. I have much more to say about Groovy testing cap-
abilities in chapter 6 on testing, but here's a simple example. There's nothing inherently
Groovy about this class except that (1) I used the map-based constructor to instantiate the
fixture, (2) optional parentheses were left out wherever possible, and (3) no explicit pub-
lic or private keywords were needed. Otherwise, this is just a regular test case, and it
works as usual.
What have I discussed in this section?
• Groovy has a convenient syntax for maps.
• XML parsing and extracting data are easy, as in the previous section.
• Groovy has a slashy syntax for regular expressions.
• Groovy classes work with JUnit tests.
Search WWH ::




Custom Search