为什么我们必须为Gradle的测试指定useTestNG()?

Xel*_*ian 6 testing testng gradle spock

如果我们想要用于我们的TestNG测试,我们必须编写如下内容:

dependencies {
   compile project(':model')
   testCompile 'org.testng:testng:6.8'
}

test.useTestNG()
Run Code Online (Sandbox Code Playgroud)

但是当使用Spock时,我们只指定依赖项

dependencies {
   compile project(':model')
   testCompile 'org.spockframework:spock-core:0.7-groovy-2.0'
}
Run Code Online (Sandbox Code Playgroud)

为什么我们必须指定test.useTestNG()

Pet*_*ser 7

Spock测试通过JUnit运行,这是Gradle的默认值.或者,可以通过TestNG运行测试.

  • 只有在需要配置JUnit特定选项时才需要`useJUnit {...}`.需要`useTestNG()`来切换到TestNG,还需要配置TestNG特定的选项. (2认同)