小编Sjo*_*erd的帖子

使用 Bundle.class 进行抑制时的 TooManyMethodsFoundException

尝试使用模拟对象运行测试时,出现以下错误:

    org.powermock.reflect.exceptions.TooManyMethodsFoundException: Several matching methods found, please specify the argument parameter types so that PowerMock can determine which method you're referring to.
Matching methods in class android.support.v7.app.AppCompatActivity were:
void onCreate( android.os.Bundle.class )
void onCreate( android.os.Bundle.class android.os.PersistableBundle.class )
void onCreate( android.os.Bundle.class )
void onCreate( android.os.Bundle.class )
void onCreate( android.os.Bundle.class )

at nl.han.alfam.presentation.CarDetailsActivityTest.setUp(CarDetailsActivityTest.java:47)
Run Code Online (Sandbox Code Playgroud)

第 47 行:

suppress(method(AppCompatActivity.class, "onCreate", Bundle.class));
Run Code Online (Sandbox Code Playgroud)

显然有多种方法支持 Bundle.class 参数。我也试过不使用 Bundle.class,但这根本没有帮助。

java android unit-testing mocking

2
推荐指数
1
解决办法
2690
查看次数

标签 统计

android ×1

java ×1

mocking ×1

unit-testing ×1