Grails Spock integration test redirectedUrl different between localhost test-app and build server test-app -
i have spock integration test looks this:
class pricetiercontrollerintegrationspec extends integrationspec { pricetiercontroller controller def setup() { controller = new pricetiercontroller() } def "applydiscount() method redirect user success view"() { when: controller.applydiscount() then: controller.response.redirectedurl == '/pricetier/success' }
then in controller, logic simply:
class pricetiercontroller { def applydiscount() { redirect action: 'success' } def success() { } }
when run spock test on local machine, test passes. however, on build server, following error:
controller.response.redirectedurl == '/pricetier/success' | | | | | | /test/success false | | 8 differences (46% similarity) | | /(t---)e(st--)/success | | /(pric)e(tier)/success | org.codehaus.groovy.grails.plugins.testing.grailsmockhttpservletresponse@dc42543 com.test.pricetiercontroller@193d6547
for reason, on build server, spock test thinks controller name test
instead of pricetier
, , test fail. seems happen spock integration tests, spock unit tests , few legacy grails mixin tests pass fine.
does know causing problem?
i've experienced same issue, , seems comes down test framework extracting controller name the name of testing class.
the convention test class named <controller name>controllerspec
in above case, test class should named pricetiercontrollerspec
test framework resolve controller priceteir
.
naming class according these guidelines seems fix problem.
further reference can found here: https://jira.grails.org/browse/grails-10962
Comments
Post a Comment