<p>My code takes an interface as input but only excercises a couple of the interface's methods (often, just getters).</p>

<p>When testing the code, I'd love to define an anonymous inner class that returns the test data.  But what do I do about all the other methods that the interface requires?</p>

<p>I could use my IDE to auto-generate a stub for the interface but that seems fairly code-heavy.  </p>

<p>What is the easiest way to stub the two methods I care about and none of the methods I don't?</p>

If you are using JUnit to test, use Mocks instead of stubs.
Read Martin Fowler's seminal article "
Mocks Aren't Stubs
"
I recommend the
EasyMock
framework, it works like a charm automatically Mocking your interface using reflection.  It is a bit more advanced than the code samples in Fowler's article, especially when you use the
unitils
library to wrap EasyMock, so the syntax will be much simpler than that in the article.  Also, if you don't have an interface, but you want to mock a concrete class, EasyMock has a class extension.