gradle - when writing spock test in groovy java mixed project unable to resolve class -
java8 gradle2.3 groovy2.4.3
sourcesets { main { java { srcdirs = [] } // no source dirs java compiler groovy { srcdir "src" } // compile in src/ groovy } test{ java {srcdirs = []} groovy{ srcdirs = ["src/test/java", "src/test/groovy"] } } }
controllerservicespec.groovy: 18: unable resolve class org.springframework.test.web.servlet.mockmvc
import info.thecodinglive.controller.teamcontroller import info.thecodinglive.service.teamservice import org.junit.runner.runwith import org.spockframework.runtime.sputnik import org.springframework.test.web.servlet.mockmvc import spock.lang.specification import static org.springframework.test.web.servlet.setup.mockmvcbuilders.* import static org.springframework.test.web.servlet.request.mockmvcrequestbuilders.*; import static org.springframework.http.httpstatus.* @runwith(sputnik) class controllerservicespec extends specification{ def teamcontroller = new teamcontroller() def teamservice = mock(teamservice) mockmvc mockmvc = standalonesetup(teamcontroller).build() def setup(){ teamcontroller.teamservice = teamservice }
dependency
{compile 'org.codehaus.groovy:groovy-all:2.4.3' testcompile group: 'junit', name: 'junit', version:'4.12' testcompile group: 'org.springframework', name: 'spring-test', version:"$springversion" testcompile group: 'org.springframework', name: 'spring-test-mvc', version:'1.0.0.m1' testcompile "cglib:cglib-nodep:3.1" testcompile('org.spockframework:spock-core:1.0-groovy-2.4') { exclude group: "org.codehaus.groovy" }
it works compile groovy/java when test controller can't find dependencies
Comments
Post a Comment