2013-08-22 147 views
0

我正嘗試使用MonkeyTalk來自動化我的Android應用程序中的黑盒測試。我面臨的問題是他們沒有任何有關使用Maven的文檔記錄。所以,經過大量研究和嘗試了很多事情之後,我讓這個構建起作用。但是,當我安裝MonkeyTalk代理時,我的應用程序崩潰。安裝MonkeyTalk代理後,我的應用程序崩潰

我不知道我的版本是否有問題,或者如果MonkeyTalk代理與我正在使用的庫不兼容。所以,這裏是我做了什麼使用Maven構建:

首先,我已經下載了MonkeyTalk並使用此命令安裝代理的JAR:

mvn install:install-file -Dfile=monkeytalk-agent-1.0.53.jar -DgroupId="com.gorillalogic.monkeytalk" -DartifactId="monkeytalk-agent" -Dversion="1.0.53" -Dpackaging="jar" 

所以,我增加了以下依賴關係:

<dependency> 
    <groupId>org.aspectj</groupId> 
    <artifactId>aspectjrt</artifactId> 
    <version>1.6.2</version> 
</dependency> 

<dependency> 
    <groupId>org.aspectj</groupId> 
    <artifactId>aspectjtools</artifactId> 
    <version>1.6.2</version> 
    <scope>provided</scope> 
</dependency> 

而且,因爲我不想被包含在每個版本的MonkeyTalk劑做,我創建了一個簡介如下:

<profile> 
    <id>monkeytalk</id> 

    <dependencies> 
     <dependency> 
      <groupId>com.gorillalogic.monkeytalk</groupId> 
      <artifactId>monkeytalk-agent</artifactId> 
      <version>1.0.53</version> 
     </dependency> 

    </dependencies> 

    <build> 
     <plugins> 
      <plugin> 
       <groupId>org.codehaus.mojo</groupId> 
       <artifactId>aspectj-maven-plugin</artifactId> 
       <version>1.4</version> 
       <configuration> 
        <source>1.6</source> 
        <target>1.6</target> 
        <aspectLibraries> 
         <aspectLibrary> 
          <groupId>com.gorillalogic.monkeytalk</groupId> 
          <artifactId>monkeytalk-agent</artifactId> 
         </aspectLibrary> 
        </aspectLibraries> 
        <showWeaveInfo>true</showWeaveInfo> 
        <verbose>true</verbose> 
        <Xlint>ignore</Xlint> 
        <outxml>true</outxml> 
       </configuration> 
       <executions> 
        <execution> 
         <!--<phase>process-sources</phase>--> 
         <goals> 
          <goal>compile</goal> 
          <goal>test-compile</goal> 
         </goals> 
        </execution> 
       </executions> 
      </plugin> 
     </plugins> 
    </build> 
</profile> 

使用此配置,構建正常工作。我在日誌中看到aspectj插件正在配置MonkeyTalk。這裏是日誌的一部分:

[INFO] Join point 'method-call(void android.widget.TextView.setText(java.lang.CharSequence))' in Type 'com.devspark.appmsg.AppMsg' (AppMsg.java:144) advised by before advice from 'com.gorillalogic.fonemonkey.aspects.SetText' (monkeytalk-agent-1.0.56.jar!SetText.class:26(from SetText.aj)) 
[INFO] Join point 'method-call(void com.devspark.appmsg.AppMsg.setText(java.lang.CharSequence))' in Type 'com.devspark.appmsg.AppMsg' (AppMsg.java:286) advised by before advice from 'com.gorillalogic.fonemonkey.aspects.SetText' (monkeytalk-agent-1.0.56.jar!SetText.class:26(from SetText.aj)) 
[INFO] Join point 'method-call(void android.widget.TextView.setText(java.lang.CharSequence))' in Type 'com.devspark.appmsg.AppMsg' (AppMsg.java:302) advised by before advice from 'com.gorillalogic.fonemonkey.aspects.SetText' (monkeytalk-agent-1.0.56.jar!SetText.class:26(from SetText.aj)) 

好了,但是當我安裝的應用程序,並嘗試打開它,我只能打開第一個畫面,這是最簡單的,只具有一些按鈕架構,通過登錄一個社交網絡或打開另一個活動。但是當我打開另一個活動時,這更復雜,應用程序崩潰。這非常奇怪,因爲在每個Android版本中,它都會崩潰,並出現不同的異常。

這一例外,例如,與Android 4.3會發生:

08-22 16:49:54.012: INFO/ActivityManager(534): START u0 {cmp=com.soongz/.ui.CadastroActivity} from pid 17633 
08-22 16:49:54.803: ERROR/AndroidRuntime(17633): FATAL EXCEPTION: main 
     java.lang.RuntimeException: Unable to start activity ComponentInfo{com.soongz/com.soongz.ui.CadastroActivity}: android.util.AndroidRuntimeException: requestFeature() must be called before adding content 
     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211) 
     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261) 
     at android.app.ActivityThread.access$600(ActivityThread.java:141) 
     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256) 
     at android.os.Handler.dispatchMessage(Handler.java:99) 
     at android.os.Looper.loop(Looper.java:137) 
     at android.app.ActivityThread.main(ActivityThread.java:5103) 
     at java.lang.reflect.Method.invokeNative(Native Method) 
     at java.lang.reflect.Method.invoke(Method.java:525) 
     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737) 
     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 
     at dalvik.system.NativeStart.main(Native Method) 
     Caused by: android.util.AndroidRuntimeException: requestFeature() must be called before adding content 
     at com.android.internal.policy.impl.PhoneWindow.requestFeature(PhoneWindow.java:226) 
     at android.app.Activity.requestWindowFeature(Activity.java:3264) 
     at android.support.v7.app.ActionBarActivityDelegateICS.supportRequestWindowFeature(ActionBarActivityDelegateICS.java:126) 
     at android.support.v7.app.ActionBarActivity.supportRequestWindowFeature(ActionBarActivity.java:150) 
     at com.soongz.ui.BaseActionBarActivity.createView(BaseActionBarActivity.java:72) 
     at com.soongz.ui.CadastroActivity.createView(CadastroActivity.java:110) 
     at br.com.cybereagle.androidlibrary.ui.helper.RetainedActivityHelper.onCreate(RetainedActivityHelper.java:42) 
     at br.com.cybereagle.androidlibrary.ui.RetainedRoboActionBarActivity.onCreate(RetainedRoboActionBarActivity.java:45) 
     at android.app.Activity.performCreate(Activity.java:5133) 
     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087) 
     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175) 
     ... 11 more 
08-22 16:49:54.813: WARN/ActivityManager(534): Force finishing activity com.soongz/.ui.CadastroActivity 
08-22 16:49:54.813: WARN/ActivityManager(534): Force finishing activity com.soongz/.ui.MainActivity 

在Android 2.2的,我有這樣的例外:

08-22 17:32:32.503: ERROR/AndroidRuntime(698): FATAL EXCEPTION: main 
     java.lang.NoClassDefFoundError: com.gorillalogic.fonemonkey.automators.AutomationManager 
     at com.gorillalogic.fonemonkey.aspects.SetListener.ajc$after$com_gorillalogic_fonemonkey_aspects_SetListener$1$bfeaeda5(SetListener.aj:30) 
     at com.soongz.service.autenticacao.AbstractAutenticador.<init>(AbstractAutenticador.java:51) 
     at com.soongz.service.autenticacao.AutenticadorFacebook.<init>(AutenticadorFacebook.java:38) 
     at com.soongz.ui.MainActivity.initializeUnretainedInstanceFields(MainActivity.java:54) 
     at br.com.cybereagle.androidlibrary.ui.helper.RetainedActivityHelper.onCreate(RetainedActivityHelper.java:34) 
     at br.com.cybereagle.androidlibrary.ui.RetainedRoboFragmentActivity.onCreate(RetainedRoboFragmentActivity.java:36) 
     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) 
     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627) 
     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679) 
     at android.app.ActivityThread.access$2300(ActivityThread.java:125) 
     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033) 
     at android.os.Handler.dispatchMessage(Handler.java:99) 
     at android.os.Looper.loop(Looper.java:123) 
     at android.app.ActivityThread.main(ActivityThread.java:4627) 
     at java.lang.reflect.Method.invokeNative(Native Method) 
     at java.lang.reflect.Method.invoke(Method.java:521) 
     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868) 
     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) 
     at dalvik.system.NativeStart.main(Native Method) 

是否有人與MonkeyTalk更有經驗的人都知道爲什麼它的代理打破我的應用?這是我的maven配置嗎?

回答

1

如果requestFeature是可選的,請嘗試刪除該行代碼。

或者把上面super.onCreate()的代碼行寫成this

This blog可能會提到相同的問題。

相關問題