GNU Emacs 24.3.1
Gradle 1.12
spock-core.0.7
Hello,
我正在做单元测试spock framework
使用gradle build
system.
当我运行测试时gradle test
我刚刚看到一条这样的消息:
* What went wrong:
Execution failed for task ':test'.
> There were failing tests. See the report at: file:///home/projs/gradleTest/build/reports/tests/index.html
然后我必须去检查xml文件,看看抛出了什么异常
有什么选项可以让我在控制台输出中看到异常吗?
例如,我想将一些打印消息打印到控制台输出:
catch(FileNotFoundException ex) {
System.out.println("Exception " + ex.toString());
}
catch(IOException ex) {
System.out.println("Exception " + ex.toString());
}
catch(Exception ex) {
System.out.println("Exception " + ex.toString());
}
我的 Gradle 构建文件:
apply plugin: 'java'
apply plugin: 'application'
apply plugin: 'groovy'
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
compile "com.googlecode.json-simple:json-simple:1.1.1"
testCompile "org.codehaus.groovy:groovy:2.3.3"
testCompile "org.spockframework:spock-core:0.7-groovy-2.0"
}
我的 spock 单元测试:
import spock.lang.Specification;
class SnapClientTest extends Specification {
def "Request from web services"() {
given:
SnapClient snapclient = new SnapClient()
expect:
snapclient.makeRequest() == 0
}
}
提前谢谢了,
当我运行我的测试 gradle 测试时,我只看到这样的消息:[...]
默认情况下,您还会看到(在输出中进一步显示):
- 哪种测试方法失败
- 异常类型
- 发生异常的源文件和行号
要查看更多信息,请配置Test#testLogging
。例如:
tasks.withType(Test) {
testLogging {
exceptionFormat "full"
}
}
欲了解更多详情,请检查Test
in the Gradle 构建语言参考.
然后我必须去检查xml文件,看看抛出了什么异常
通常您会检查 HTML 报告,而不是 XML 文件。在 Mac 上,您只需按住 CMD 并双击文件 URL 即可打开报告See the report at:
。一些 *nix 终端提供类似的功能。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)