【发布时间】:2018-01-17 17:03:40
【问题描述】:
我想运行一个功能测试来查看 Gradle 插件任务的输出,这些输出是一系列文件。我正在使用GradleRunner,其测试类似于TestKit docs 中的测试,但使用Spock 运行。
@Rule public final TemporaryFolder testProjectDir = new TemporaryFolder();
private File buildFile;
def setup() {
buildFile = testProjectDir.newFile("build.gradle");
buildFile << """
plugins {id 'com.myplugin.id'}
"""
}
def "my plugin task creates myfile.txt inside build dir"() {
given:
when:
def result = GradleRunner.create()
.withProjectDir(testProjectDir.root)
.withPluginClassPath()
.withArguments("mytask")
.build();
then:
result.task(":mytask").getOutcome() == SUCCESS
new File(testProjectDir.root.absolutePath + "/build", "myfile.txt").exists()
}
我只是没有看到在我的临时目录中创建了build 目录。构建工件放在哪里?
【问题讨论】: