Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple when/then with where for each other

I'm trying to write functional test with Spock and Geb. I want to use in one test method multiple blocks of when/then with where for each block. Is it possible? Or I should use one where for all the when/then?

like image 671
uladzimir Avatar asked Nov 21 '13 09:11

uladzimir


1 Answers

You will not be able to use where per interaction, it would complain about the usage. You would end up with a single where for multiple interactions. Follow this as a sample:

def test() {
  given:   
  def c
  def d

  when:
  c = a + b

  then:
  c == result

  when:
  d = e - f

  then:
  d == res

  where:
  a | b |result | e |f |res
  1 | 2 | 3     | 7 |5 |2
}
like image 126
dmahapatro Avatar answered Oct 02 '22 01:10

dmahapatro