What is the proper way to setup integration tests in grails 2.5 using junit? -


with grails 2.2 following code (which integration test gorm class) working fine:

public class dbdeploymentintegrationtests extends groovytestcase {   deploymentstorageimpl deploymentstorage    deploymentservice deploymentservice    @override   protected void setup()   {     super.setup()     deploymentstorage = deploymentservice.deploymentservice.deploymentstorage   } ... } 

when updated grails 2.5, failing:

| failure:  testincludedetails(org.linkedin.glu.console.domain.dbdeploymentintegrationtests) |  java.lang.nullpointerexception: cannot property 'deploymentservice' on null object     @ org.linkedin.glu.console.domain.dbdeploymentintegrationtests.setup(dbdeploymentintegrationtests.groovy:41) 

the documentation (http://grails.github.io/grails-doc/2.5.0/guide/upgradingfrom22.html) states following:

dependency injection integration tests

in order support alternate junit4 test runners, grails 2.3 no longer uses special test runner run tests , integration tests should no longer extend groovytestcase.

this change requires junit integration tests require dependency injection need annotated with:

@testmixin(integrationtestmixin)

i tried adding annotation , has no effect: code still fails in setup method. if comment out setup , access deploymentservice directly in test method work. dependency injection happens. not in setup method. , used work properly.

any idea how fix issue?

thanks

see https://jira.grails.org/browse/grails-10584

your test should not extend groovytestcase instead should use junit 4 style


Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -