Unitils

Add ability to specify default behavior for mocks. (find best match for invocations)

Details

  • Type: Improvement Improvement
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 2.3
  • Fix Version/s: 3.0
  • Component/s: mock
  • Description:
    Hide
    For example:

            mockObject.returns("value1").testMethod(null, null, null);
            mockObject.returns("value2").testMethod("arg1", null, null);

    should return value2 if invoked with "arg1" as first argument value.

    This way you could for example specify the default behavior in the before method and then specify more specific behavior in the test methods.

    E.g

    public class MyTest {

        @Before
        public void setDefaults(){
            mockObject.returns("value1").testMethod(null, null, null);
        }

        @Test
        public void myTest(){
             mockObject.returns("value2").testMethod("arg1", null, null);
             ....
        }
    }
    Show
    For example:         mockObject.returns("value1").testMethod(null, null, null);         mockObject.returns("value2").testMethod("arg1", null, null); should return value2 if invoked with "arg1" as first argument value. This way you could for example specify the default behavior in the before method and then specify more specific behavior in the test methods. E.g public class MyTest {     @Before     public void setDefaults(){         mockObject.returns("value1").testMethod(null, null, null);     }     @Test     public void myTest(){          mockObject.returns("value2").testMethod("arg1", null, null);          ....     } }

Activity

There are no comments yet on this issue.

People

Dates

  • Created:
    21/Jul/09 9:56 AM
    Updated:
    21/Jul/09 10:05 AM
    Resolved:
    21/Jul/09 10:05 AM