You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is no reason to have a unit test like that of course but this is a simple example that demonstrates the problem. The second test method will fail with the following:
Condition failed with Exception:
service.list().size() == 0
|
java.lang.reflect.InvocationTargetException
at servicetestproblem.PersonServiceSpec.second test(PersonServiceSpec.groovy:20)
Caused by: java.lang.reflect.InvocationTargetException
at grails.testing.services.ServiceUnitTest$Trait$Helper.mockArtefact(ServiceUnitTest.groovy:66)
at org.grails.testing.ParameterizedGrailsUnitTest$Trait$Helper.getArtefactInstance(ParameterizedGrailsUnitTest.groovy:48)
at grails.testing.services.ServiceUnitTest$Trait$Helper.getService(ServiceUnitTest.groovy:83)
... 1 more
Caused by: java.lang.IllegalStateException: Could not register object [servicetestproblem.$PersonServiceImplementation@42339ea2] under bean name 'personService': there is already object [servicetestproblem.$PersonServiceImplementation@42339ea2] bound
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.registerSingleton(DefaultSingletonBeanRegistry.java:130)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.registerSingleton(DefaultListableBeanFactory.java:936)
at grails.testing.gorm.DataTest$Trait$Helper.mockDataService(DataTest.groovy:101)
... 4 more
The text was updated successfully, but these errors were encountered:
See https://github.com/jeffbrown/servicetestproblem
Domain:
Data Service:
Unit test:
There is no reason to have a unit test like that of course but this is a simple example that demonstrates the problem. The second test method will fail with the following:
The text was updated successfully, but these errors were encountered: