at android.util.Log.println_native(Native Method)
at android.util.Log.e(Log.java:240)
```
6.外部新建類(lèi)繼承該源碼類(lèi):因該類(lèi)只有有參構(gòu)造函數(shù),繼承出來(lái)的類(lèi)中的構(gòu)造函數(shù)還是要執(zhí)行super才行,否則報(bào)錯(cuò):`There is no default constructor available in 'com.desaysv.adapter.sceneengine.ActionExecuter'` *Failed*
7.在第6方法上,繼承后,寫(xiě)一個(gè)有參構(gòu)造函數(shù),再寫(xiě)一個(gè)無(wú)參構(gòu)造函數(shù),也不行。和6同理 *Failed*
8.放棄,改源碼,加個(gè)無(wú)參構(gòu)造函數(shù),也不行,和6、7同樣情況 *Failed*
9.沒(méi)法搞,該類(lèi)暫無(wú)法單元測(cè)試,使用實(shí)機(jī)的灰盒繼承測(cè)試
```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ò)問(wèn)題
```
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
```
問(wèn)題點(diǎn)可能出現(xiàn)在@config()中無(wú)法配置如下內(nèi)容導(dǎo)致,仍待研究。。。
```objectivec
constants = BuildConfig.class
```
七、模擬測(cè)試回調(diào)函數(shù)時(shí),用powermock或者M(jìn)ockito.doAnswer()都可以,因此可以運(yùn)用在安卓實(shí)機(jī)測(cè)試上,如: