1
我有一个斯波克集成测试,看起来是这样的:Grails的斯波克集成测试redirectedUrl本地主机测试应用程序,并构建服务器测试应用程序之间的不同
class PriceTierControllerIntegrationSpec extends IntegrationSpec {
PriceTierController controller
def setup() {
controller = new PriceTierController()
}
def "applyDiscount() method will redirect user to success view"() {
when:
controller.applyDiscount()
then:
controller.response.redirectedUrl == '/priceTier/success'
}
然后在控制器,逻辑很简单:
class PriceTierController {
def applyDiscount() {
redirect action: 'success'
}
def success() {
}
}
当我在本地机器上运行这个Spock测试时,测试通过。然而,在构建服务器,我收到以下错误:
controller.response.redirectedUrl == '/priceTier/success'
| | | |
| | /test/success false
| | 8 differences (46% similarity)
| | /(t---)e(st--)/success
| | /(pric)e(Tier)/success
| org.codeh[email protected]dc42543
[email protected]
出于某种原因,在构建服务器时,斯波克测试认为,控制器名称是test
而不是priceTier
,测试将失败。这似乎只发生在Spock集成测试中,因为Spock单元测试和一些遗留的Grails mixin测试都通过正常。
有没有人知道可能会导致这个问题?
,请复制粘贴你用你的本地计算机上运行测试和构建服务器的命令。你使用不同的environemnt设置? –