Reputation: 61
I am learning the FitNesse framework and wondering if fixture code can be written in Groovy. So I made a copy of an example Decision Table, renamed the original class as ShouldIBuyMilkJava
and created a Groovy class with same functionality. So my setup is like this:
wiki test page (table rows omitted for brevity):
|should I buy milk Java |
|cash in wallet|credit card|pints of milk remaining|go to store?|
|0 |no |0 |no |
|10 |no |0 |yes |
|should I buy milk Groovy |
|cash in wallet|credit card|pints of milk remaining|go to store?|
|0 |no |0 |no |
|10 |no |0 |yes |
ShouldIBuyMilkJava.java:
Same as here, except that the class is renamed to ShouldIBuyMilkJava
ShouldIBuyMilkGroovy.groovy:
class ShouldIBuyMilkGroovy {
def dollars
def pints
boolean creditCard
ShouldIBuyMilkGroovy() {
}
// the rest is omitted for brevity
Both classes are compiled successfully and are located in a folder that is imported as classpath in the test page. The first test passes successfully, but for the second I get an exception Could not invoke constructor for ShouldIBuyMilkGroovy[0]
.
I've tried removing an empty no-arg constructor from Groovy class - same result.
How can I make Groovy classes work as FitNesse fixtures?
Upvotes: 0
Views: 113
Reputation: 61
So, the fix is simple - I had to include !path
directive pointing at groovy library into FitNesse root
page, not into the test page.
Upvotes: 0