Constructor and createStrictMock

30 views
Skip to first unread message

Sven

unread,
May 28, 2012, 8:22:34 AM5/28/12
to androi...@googlegroups.com
Hello,

I have the following situation:
public class ClassToMock {
public ClassToMock(AnAbstractDependency d) { ... }
...
}

public abstract class AnAbstractDependency {
public AnAbstractDependency(/*More Dependences*/ ...) { ... }
...
}

public abstract class TestDependency extends AnAbstractDependency {
...
}

// In my test class:
public void testSomething() {
TestDependency testDependency = ...;
ClassToMock mock = AndroidMock.createStrictMock(ClassToMock.class, testDependency);
}

If I run my tests, I get an:
java.lang.IllegalArgumentException: Could not find the specified Constructor: [...]
I don't understand why i get this Exception because there is an matching constructor. Ok, it's a derivative of this class, but why is this a problem?

Or is there anyway to tell AndroidMock, that I don't care about that he find correct constructor?
(I don't want to mock AnAbstractDependency because it then I have to mock more dependences, that I don't need. And to add an addtional constructor only for testing is bad.)

Thanks, 
Sven
Reply all
Reply to author
Forward
0 new messages