PowerMockBuildConfig在测试期间设置字段值时似乎不会更改字段值。
目前我有这些 BuildConfig
public static final String SAMPLE_FIELD = "Sample Value";
Run Code Online (Sandbox Code Playgroud)
我想将其更改为其他值(例如,“另一个值”)
我试过了,Whitebox但它不起作用。
Whitebox.setInternalState(BuildConfig.class , "SAMPLE_FIELD" , "Another Value");
Field f = Whitebox.getField(BuildConfig.class, "SAMPLE_FIELD");
f.setAccessible(true);
f.set(String.class , "Another Value");
Run Code Online (Sandbox Code Playgroud)
这真的有用吗,或者这是改变这些值的另一种方法?
| 归档时间: |
|
| 查看次数: |
843 次 |
| 最近记录: |