Spock Web Console

subscribe to the feed Subscribe
Mock Sample (via #spockwebconsole)
tweet this script Tweet

Mock Sample

Published 2 years ago by Evgeny Goldin
Actions  ➤ Edit In Console Back To Console Show/Hide Line Numbers View Recent Scripts
import spock.lang.Specification

interface M { int sum( int a, int b ) }

class SampleSpec extends Specification 
{
    def "mock-sample"( x, y, z )
    {
        given: M   m      = Mock()
        when : int result = m.sum( x, y )
        then : 1 * m.sum( x, y ) >> ( x + y ) 
               result == z 
        where:
        x | y | z
        1 | 2 | 3
        0 | 5 | 5 
    }
 }