Spock Web Console

subscribe to the feed Subscribe
Demonstrate Spock Exception Handling (via #spockwebconsole)
tweet this script Tweet

Demonstrate Spock Exception Handling

Published 2 years ago by Warren Smith with tags exception failswith
Actions  ➤ Edit In Console Back To Console Show/Hide Line Numbers View Recent Scripts
import spock.lang.*

class ExceptionHandlerSpec extends Specification {
    def "Expect a failure using annotation"() {
        expect: Integer.parseInt("99", 8)

    def "Expect a failure"() {
        Integer.parseInt("99", 8)
        NumberFormatException e = thrown()
        e.message == 'For input string: "99"'
    def "Expect a failure not true"() {
        Integer.parseInt("-2147483648", 10)

        notThrown(NumberFormatException )