at android.util.Log.println_native(Native Method)
at android.util.Log.e(Log.java:240)
```
6.外部新建類繼承該源碼類:因該類只有有參構(gòu)造函數(shù),繼承出來的類中的構(gòu)造函數(shù)還是要執(zhí)行super才行,否則報(bào)錯(cuò):`There is no default constructor available in 'com.desaysv.adapter.sceneengine.ActionExecuter'` *Failed*
7.在第6方法上,繼承后,寫一個(gè)有參構(gòu)造函數(shù),再寫一個(gè)無參構(gòu)造函數(shù),也不行。和6同理 *Failed*
8.放棄,改源碼,加個(gè)無參構(gòu)造函數(shù),也不行,和6、7同樣情況 *Failed*
9.沒法搞,該類暫無法單元測試,使用實(shí)機(jī)的灰盒繼承測試
```cpp
java.lang.NullPointerException
at com.desaysv.adapter.sceneengine.manager.MediaManagerTest.init(MediaManagerTest.java:57)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.internal.runners.TestMethod.invoke(TestMethod.java:68)
at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner.runTestMethod(PowerMockJUnit44RunnerDelegateImpl.java:316)
at org.junit.internal.runners.MethodRoadie$2.run(MethodRoadie.java:89)
at org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(MethodRoadie.java:97)
at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner.executeTest(PowerMockJUnit44RunnerDelegateImpl.java:300)
```
四、Mockito.verify()參數(shù)報(bào)錯(cuò)問題
```
org.mockito.exceptions.misusing.InvalidUseOfMatchersException:
Invalid use of argument matchers!
3 matchers expected, 1 recorded:
-> at com.desaysv.adapter.sceneengine.manager.MediaManagerTest.init(MediaManagerTest.java:59)
This exception may occur if matchers are combined with raw values:
//incorrect:
someMethod(anyObject(), "raw String");
When using matchers, all arguments have to be provided by matchers.
For example:
//correct:
someMethod(anyObject(), eq("String by matcher"));
```
方法:按照要求修改參數(shù),如Matchers.eq(Target.RADIO),改為:
```objectivec
WARNING: No manifest file found at .\AndroidManifest.xml.
No such manifest file: .\AndroidManifest.xml
Falling back to the Android OS resources only.
To remove this warning, annotate your test class with @Config(manifest=Config.NONE).
[Robolectric] com.desaysv.adapter.sceneengine.manager.RoboTest.myTest: sdk=27; resources=legacy
[Robolectric] NOTICE: legacy resources mode is deprecated; see robolectric點(diǎn)org/migrating/#migrating-to-40
```
問題點(diǎn)可能出現(xiàn)在@config()中無法配置如下內(nèi)容導(dǎo)致,仍待研究。。。
```objectivec
constants = BuildConfig.class
```
七、模擬測試回調(diào)函數(shù)時(shí),用powermock或者M(jìn)ockito.doAnswer()都可以,因此可以運(yùn)用在安卓實(shí)機(jī)測試上,如: