Spock - How to use multiple def in single class???

30 views
Skip to first unread message

Lucky

unread,
May 15, 2012, 4:07:47 PM5/15/12
to Spock Framework - User
In the following code all the validations are same only the passing
xml will change. Able to print the result for the second one if I
comment second def then able to print result for first one. But I want
to print both at the same time...

Following is the code i m using,

class Test extends Specification {

def " Hospital Test Validations"(){
given:
File Test = new File ("./hosp.xml")
Validator vd = new Validator(Test)
when:
List<String> result = vd.validate()
then:
println result
}

def " Message Test Validations"(){
given:
File Test = new File ("./msg.xml")
Validator vd = new Validator(Test)
when:
List<String> result = vd.validate()
then:
println result
}
}
RESULT :

The second output is getting printed in console but in JUNIT both of
them are passed. Did debug and noticed that after first def everything
is getting cleared and then second one is running. Is there a way to
capture both results at the same time in console.

Really appreciate your help on this.

Luke Daley

unread,
May 16, 2012, 5:52:40 AM5/16/12
to spockfr...@googlegroups.com
What do you mean by “in JUNIT”?

Aruna

unread,
May 16, 2012, 9:01:08 AM5/16/12
to spockfr...@googlegroups.com
I am running this as JUNIT Run Test and in JUNIT Console all tests are passed.

Regards,

Aruna.


--
You received this message because you are subscribed to the Google Groups "Spock Framework - User" group.
To post to this group, send email to spockfr...@googlegroups.com.
To unsubscribe from this group, send email to spockframewor...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/spockframework?hl=en.




--
Regards,

Aruna.

Peter Niederwieser

unread,
May 16, 2012, 5:46:46 PM5/16/12
to spockfr...@googlegroups.com
I'm unable to reproduce this. When I run the following spec in Eclipse, I see _all_ output in the console:

class MySpec extends Specification {
  def foo() {
    when:
    def msg = "foo"
    then:
    println msg
  }
  def bar() {
    when:
    def msg = "bar"
    then:
    println msg
  }
}

Cheers,
Peter
Reply all
Reply to author
Forward
0 new messages