English 中文(简体)
使用@ 对使用构造论点的星体进行单位测试,会产生错误(Grails 2.0.0RC1)。
原标题:Using @TestFor in unit test for bean that uses constructor arguments throws an error (Grails 2.0.0RC1)
  • 时间:2011-11-23 12:25:31
  •  标签:
  • grails

I m trying to create a unit test for a service class that uses a constructor argument. I have already configured an entry in the grails-app/conf/spring/resources.groovy to allow Spring to create the bean using the constructor argument.

Running an integration test for the service class works without problem, however, running a unit test that uses @TestFor, the following exception shows up:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name  sampleService : Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [ph.jojopad.SampleService]: No default constructor found; nested exception is java.lang.NoSuchMethodException: ph.jojopad.SampleService.<init>()
    at grails.test.mixin.services.ServiceUnitTestMixin.mockService(ServiceUnitTestMixin.groovy:54)
Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [ph.jojopad.SampleService]: No default constructor found; nested exception is java.lang.NoSuchMethodException: ph.jojopad.SampleService.<init>()
Caused by: java.lang.NoSuchMethodException: ph.jojopad.SampleService.<init>()

看来,“......选择”只期望一个使用违约构造的灯。 看看Grails I的文献,看不出任何关于如何使用@For for beans和有建筑论者的说法。 我期望,有了正确的铁路组合,即铁路-应用/组合/资源。 干.会.。

问题回答

暂无回答




相关问题
grails + gwt request handling via controllers

I am new to gwt. I am trying to integrate gwt+grails.Can anybody provide me a good example for handling the request using grails controllers and not a custom servlet.I will be really thankful if ...

Error loading the grails gwt module xml

I ve installed the plugin from this article by Peter http://www.cacoethes.co.uk/blog/groovyandgrails/the-command-pattern-w.... While compile time its not able to find the module file which is present ...

Sorting Objects Based on Custom Domain Class Methods

I have a domain class, in which I ve defined some methods which give the object a score based on different algorithms (eg. popularity). I now want to retrieve a list of these objects sorted by one of ...

Grails Packaging and Naming Conventions

Packaging Controllers, Services,etc. i.e. - com.company.controllers - com.company.services Is this a good practice or should be avoided by all means?? Another worth mentioning problem I encountered ...

Hibernate/GORM: collection was not processed by flush()

I have an integration test in my Grails application that fails when I try to save an entity of type Member invitingMember.save(flush: true) This raises the following exception org.hibernate....

热门标签