【发布时间】:2017-02-03 11:12:19
【问题描述】:
我的项目的技术堆栈是 Grails 3.2.3、Groovy 2.4.7、Gradle 3.2.1、GORM 和 IDE 是 Intellij,后端是 MongoDB。 我已经实现了 Spock Integraction 测试类 TestControllerSpec 并想运行单个 Spock 集成测试 为了运行单个测试用例需要进行哪些配置更改以及如何更改?
@Integration
@Rollback
class TestControllerSpec extends Specification {
@Unroll
void "temp listObjects"(){
def result
def params = [id: '123']
when:
result = controller.index(10)
then:
result == null
result.size()==0
}
}
【问题讨论】:
-
如果您在 IntelliJ 中,您能否不只是右键单击规范中的任意位置并告诉它运行该测试?
-
您检查过 grails-spock 集成中的documentation 吗? Gradle 可以使用命令行参数模式(gradle docs、examples)执行单个测试,例如
gradle test --tests org.gradle.SomeTest.someSpecificFeature -
如果这是来自 IntelliJ 内部,您可以使用 intellij-gradle 集成并在 intellij 内部使用上述
--tests参数运行“测试”任务。 -
Task.leftShift(Closure) 方法已被弃用,并计划在 Gradle 5.0 中删除。请改用 Task.doLast(Action)。在 build_cib62r8qsn00vq0cqu7xznhk6.run(C:\MyProject\build.gradle:23)。 *** 即使第 23 行评论 //apply plugin:"org.grails.grails-web" 也不起作用