|
Groovy example source code file (Groovy3403Bug.groovy)
The Groovy Groovy3403Bug.groovy source codepackage groovy.bugs import groovy.mock.interceptor.StubFor class Groovy3403Bug extends GroovyTestCase { void testStubIssueForStaticMethodsDueToCallSiteCachingWhenUsing2Stubs() { def stub1 = new StubFor(Main3403) stub1.demand.test() { return "stubbed call made - 1" } def ot = new Helper3403() stub1.use { assert ot.doTest() == "stubbed call made - 1" } def stub2 = new StubFor(Main3403) stub2.demand.test() { return "stubbed call made - 2" } // the following stubbed call is on stub2 and its demand count should be separate. // Currently due to caching of MockProxyMetaClass, it gets counted towards stub1 demands // and throws "End of demands" exception stub2.use { assert ot.doTest() == "stubbed call made - 2" } } } class Main3403 { static test(){ println "original call made" } } class Helper3403 { def doTest() { Main3403.test() } } Other Groovy examples (source code examples)Here is a short list of links related to this Groovy Groovy3403Bug.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.