Spock Web Console

subscribe to the feed Subscribe
Spock Interactions (via #spockwebconsole)
tweet this script Tweet

Spock Interactions

Published 6 months ago by dmahapatro with tags groovy spock
Actions  ➤ Edit In Console Back To Console Show/Hide Line Numbers View Recent Scripts
import spock.lang.*

// Hit 'Run Script' below
class MyFirstSpec extends Specification {
  def "let's try this!"() {
    when:
    new Test().method('Good')
    
    then:
    noExceptionThrown()

    when:
    new Test().method('Bad')

    then:
    thrown(Exception)
  }

  class Test {  
      def method(String param) {
        if(param == 'Good') {
            return param 
        }

        throw new Exception()
      }
  }
}