Passing arguments to constructors

In this first examples, the base objects were assumed to have no-arg constructors. That is not always the case. When arguments are passed to its createStub method, SimpleStub will look for a matching constructor and call it. For example:

        abstract class FakeObject extends BaseObject {
            FakeObject(int count, String... names) {
                super(count, names);
            }

            :
            behavior needed for test
            :
        }

        @Test
        public void testListofString() {
            FakeObject fake = Stub.createStub(8, "Joe", "Sam", "Susan");
            :
            rest of test
            }
        }

Detecting unexpected method calls

In most cases, calls to methods not specifically implemented can be treated as no-ops. There are some cases, however, where it is useful to be able to find out if an unexpected call is being made. Calling createStrictStub will create an object that throws an UnexpectedMethodCallException if one of the generated methods is called.