私はJMockitが簡単にそれを完全に切り替えて使用することを発見しました。テストケースを使用してそれを参照してください:
https:// github .com/ko5tik/andject/blob/master/src/test/java/de/pribluda/android/andject/ViewInjectionTest.java
ここで私はAndroidのSKDから来て、完全にアクティビティベースのクラスを嘲笑します
スタブ。 JMockitを使うと、最終的なもの、私的なもの、抽象的なもの、その他のものを模倣することができます。
あなたのテストケースでは次のようになります:
public void testFoo(@Mocked final Method targetMethod,
@Mocked final CacheContext context,
@Mocked final CacheExpire ce) {
new Expectations() {
{
//specify expected sequence of infocations here
context.getTargetMethod(); returns(method);
}
};
//call your method
assertSomething(objectUndertest.cacheExpire(context))