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

MockFor does not work properly with zero ranges

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.1-rc-2
    • 1.1-rc-3
    • None
    • None

    Description

      I want to use MockFor for testing that, in the case of certain start up parameter combination, a certain point in a startup script of my application is not reached, . This point is defined by a call to a method of a particular class. To check this I do:

      MockFor mockForX = new MockFor(X)
      mockForX.demand.myMethod(0..0)
      mockForX.use {
         Main.main(args)
      }
      

      This works, i.e. an AssertionFailedException is thrown, if during the processing of the main method, X.myMethod is called. The problem is, that an AssertionFailedException is also thrown, if X.myMethod is not called. It say the following:

      junit.framework.AssertionFailedError: verify[0]: expected 0..0 call(s) to 'myMethod' but was never called.

      A work around I see is to make use of the fact that in Groovy the main method might return an argument.

      I might be able and have time to submit a patch tomorrow.

      Attachments

        1. ZeroRange.patch
          5 kB
          Hans Dockter
        2. MockForWithZeroRangeTest.groovy
          0.8 kB
          Hans Dockter

        Activity

          People

            ait Alex Tkachman
            hans_d Hans Dockter
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: