Thanks. I think that the might achieve what I was after. Since there was some confusion
about what I really want to do, and why, I'll try to give you an example, but
I'm going to have to show it in pseudo-java.
public class Foo
{
public void doSomething(Bar bar)
{ ... }
}
now, I want to write code that tests Foo.doSomething. I want that
test to be independent of any problems that Bar might have. So,
I write this...
public class FooTest
{
testDoSomething()
{
class MockBar extends Bar
{
// code to simulate a "Bar"
}
...
bar = new MockBar();
foo = new Foo();
foo.doSomething(bar);
// check that the right things happened to bar
}
}