Groovy MarkupBuilder代码在Grails集成中不起作用

时间:2014-02-13 07:18:37

标签: grails groovy

我刚刚在Groovy网站上使用了关于我的Grails项目中的markbuilder的代码:

def writer = new StringWriter()
def xml = new MarkupBuilder(writer)
xml.records() {
  car(name:'HSV Maloo', make:'Holden', year:2006) {
    country('Australia')
    record(type:'speed', 'Production Pickup Truck with speed of 271kph')
  }
  car(name:'P50', make:'Peel', year:1962) {
    country('Isle of Man')
    record(type:'size', 'Smallest Street-Legal Car at 99cm wide and 59 kg in weight')
  }
  car(name:'Royale', make:'Bugatti', year:1931) {
    country('France')
    record(type:'price', 'Most Valuable Car at $15 million')
  }
}

然后我在Grails中为此编写单元和集成测试。

然而,单元测试通过,但集成测试抛出了一些异常:

No such property: car for class: xxxxxxx
Possible solutions: class
groovy.lang.MissingPropertyException: No such property: car for class: xxxxxxx
Possible solutions: class
    at GrailsMelodyGrailsPlugin.closure4_closure16_closure17(GrailsMelodyGrailsPlugin.groovy:162)
    at 

即使我引用元素汽车,国家和唱片,它仍然有同样的问题。

0 个答案:

没有答案