Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-6370

MockFor and proxyInstance() fail in some situations.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 2.1.7
    • None
    • groovy-jdk, mocks and stubs
    • None
    • OS X (my environment) and Ubuntu (coworker's environment).

    Description

      The attached test demonstrates the problem. The two test methods will not both succeed. Whichever one runs first will succeed and the second will fail.

      I attempted to mock simple classes instead of the RestTemplate and netflix Curator classes, but was not able to duplicate the problem that way. This is some kind of weird interaction between groovy mocks and those classes.

      The attached build.gradle references the versions of those spring and netflix dependencies that we use. This also fails using groovy 2.0.1, but does NOT fail under groovy 1.8.8.

      In case you don't want to look at the attached code, one of these two methods will fail when called sequentially, but not when executed individually:

          @Test
          void testOne( ) {
              def mockRestTemplate = new MockFor( RestTemplate )
              mockRestTemplate.proxyInstance()
          }
      
          @Test
          void testTwo( ) {
              def mockFramework = new MockFor( CuratorFramework )
              def mockReaper = new MockFor( Reaper )
              def framework = mockFramework.proxyInstance()
              mockReaper.proxyInstance( framework )
          }
      

      Attachments

        1. build.gradle
          0.5 kB
          Ray A. Conner
        2. FailingMockTest.groovy
          0.6 kB
          Ray A. Conner

        Activity

          People

            Unassigned Unassigned
            rconner Ray A. Conner
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: