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

MockFor and StubFor improvements

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.7.0
    • 1.7.1, 1.8-beta-1
    • mocks and stubs
    • None
    • Patch

    Description

      MockFor and StubFor provide powerful features for mocking but it would be good to have some additional convenience methods and enhancements.

      • Proposed number of times feature:
        mock.demand.hasNext(3) { true }
        

        as shorthand for:

        mock.demand.hasNext(3..3) { true }
        
      • Proposed ignore feature supports code fragments like:
        def mock = new MockFor(AlphaIterator)
        def expectedCount = 2
        mock.ignore('next'){ /* ignored */ }
        mock.demand.hasNext(expectedCount){ true }
        mock.demand.hasNext{ false }
        mock.use {
           assert new IteratorCounter().count(new AlphaIterator()) == expectedCount
        }
        

      Attachments

        Issue Links

          Activity

            People

              paulk Paul King
              paulk Paul King
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: