|
Groovy example source code file (MockWithZeroRangeTest.groovy)
The Groovy MockWithZeroRangeTest.groovy source codepackage groovy.mock.interceptor import groovy.mock.interceptor.MockFor import junit.framework.AssertionFailedError class MockForWithZeroRangeTest extends GroovyTestCase { void testMockWithZeroRangeDemandAndNoCall() { MockFor mockForFoo = new MockFor(Foo) mockForFoo.demand.createBar(0..0) {} mockForFoo.use { println 'Foo is not called' } // We should get here and the test should pass. } void testMockWithZeroRangeDemandAndOneCall() { MockFor mockForFoo = new MockFor(Foo) mockForFoo.demand.createBar(0..0) {} shouldFail(AssertionFailedError) { mockForFoo.use { new Foo().createBar() } } } } class Foo { def createBar() { println 'bar' } } Other Groovy examples (source code examples)Here is a short list of links related to this Groovy MockWithZeroRangeTest.groovy source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.