Tuesday, 15 March 2011

java - Output unit testing results on console using spock junit testing and gradle build system -



java - Output unit testing results on console using spock junit testing and gradle build system -

gnu emacs 24.3.1 gradle 1.12 spock-core.0.7

hello,

i doing unit testing spock framework using gradle build system.

when run tests gradle test see message this:

* went wrong: execution failed task ':test'. > there failing tests. see study at: file:///home/projs/gradletest/build/reports/tests/index.html

then have go , check xml file see exception has been thrown

is there alternative see exceptions in console output? illustration have print message printed console output:

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()); }

my gradle build file:

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" }

my spock unit test:

import spock.lang.specification; class snapclienttest extends specification { def "request web services"() { given: snapclient snapclient = new snapclient() expect: snapclient.makerequest() == 0 } }

many in advance,

when run tests gradle test see message this: [...]

by default, you'll see (further in output):

which test method(s) failed the exception type the source file , line number exception occurred

to see more information, configure test#testlogging. example:

tasks.withtype(test) { testlogging { exceptionformat "full" } }

for farther details, check test in gradle build language reference.

then have go , check xml file see exception has been thrown

typically check html report, not xml file. on mac can open study holding downwards cmd , double-clicking file url after see study at:. *nix terminals offer similar feature.

java gradle spock

No comments:

Post a Comment