uladzimir
uladzimir

Reputation: 5689

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?

Upvotes: 9

Views: 10268

Answers (1)

dmahapatro
dmahapatro

Reputation: 50245

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
}

Upvotes: 14

Related Questions