Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Controller unit tests stopped working. #10

Open
verglor opened this issue Aug 9, 2018 · 4 comments
Open

Controller unit tests stopped working. #10

verglor opened this issue Aug 9, 2018 · 4 comments

Comments

@verglor
Copy link

verglor commented Aug 9, 2018

After installing this plugin all controller unit tests throws NoSuchBeanDefinitionException: No qualifying bean of type 'org.grails.plugins.htmlcleaner.HtmlCleaner' available:

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'TestController': Unsatisfied dependency expressed through method 'setHtmlCleaner' parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.grails.plugins.htmlcleaner.HtmlCleaner' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.inject(AutowiredAnnotationBeanPostProcessor.java:667)
	at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:366)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1264)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:325)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
	at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1080)
	at grails.testing.web.GrailsWebUnitTest$Trait$Helper.mockController(GrailsWebUnitTest.groovy:132)
	at grails.testing.web.controllers.ControllerUnitTest$Trait$Helper.mockArtefact(ControllerUnitTest.groovy:83)
	at org.grails.testing.ParameterizedGrailsUnitTest$Trait$Helper.getArtefactInstance(ParameterizedGrailsUnitTest.groovy:48)
	at grails.testing.web.controllers.ControllerUnitTest$Trait$Helper.getController(ControllerUnitTest.groovy:100)
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.grails.plugins.htmlcleaner.HtmlCleaner' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1493)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1104)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1066)
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.inject(AutowiredAnnotationBeanPostProcessor.java:659)
	... 13 more
@snimavat
Copy link
Owner

snimavat commented Aug 9, 2018

Oh yeah, the bean wont be available during unit tests coz plugin doesnt run in unit tests, u will have to define the mock bean your self. See grails docs for how to defineBeans during unit tests

@verglor
Copy link
Author

verglor commented Aug 10, 2018

I think it is not a very good behavior of a plugin to corrupt all unrelated unit tests.
Is it really necessary to add cleanHtml method to every controller in this way?

@taschukMax
Copy link

taschukMax commented Jan 30, 2019

I would agree with @verglor . It would be nice to not have this problem or at least to have it mentioned in documentation.

@snimavat
Copy link
Owner

@taschukMax - Any PR Welcome

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants