0
我在用groovy编写的JUnit测试代码中执行了一些命令,但命令的输出未显示在gradle测试报告中。有谁知道为什么发生这种情况?命令的输出不显示在gradle测试报告的标准输出中
以下是我的简化代码:
package org.myorg.myapp
import org.apache.commons.exec.CommandLine
import org.apache.commons.exec.DefaultExecutor
import org.junit.Test
class MyTest {
@Test
void executelsCommand() {
println("Started.")
String line = "ls"
CommandLine cmdLine = CommandLine.parse(line)
DefaultExecutor executor = new DefaultExecutor()
int exitValue = executor.execute(cmdLine)
println("Finished.")
}
}
的build.gradle:
apply plugin: 'java'
apply plugin: 'groovy'
repositories {
mavenCentral()
}
dependencies {
compile 'org.codehaus.groovy:groovy-all:2.3.3'
testCompile 'org.apache.commons:commons-exec:1.2'
testCompile 'junit:junit:4.11'
}
test {
testLogging.showStandardStreams = true
}
执行上面的代码的结果如下:
如果我执行上面的代码在我的eclipse中使用Run As - > JUnit Te st,ls命令的输出成功显示在控制台窗口中。
谢谢你的答案,但它不工作。我用build.gradle编辑了我的问题。 – 2014-09-29 12:43:52