android 几款比较好用的测试工具

1. Hugo

项目地址:https://github.com/JakeWharton/hugo

工程build.gradle:

   

dependencies {
       classpath 'com.jakewharton.hugo:hugo-plugin:1.2.1'
   }


项目build.gradle

apply plugin: 'com.jakewharton.hugo'
1
使用: 在方法体添加 @DebugLog 

  @DebugLog
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        add(1, 8);
    }
    @DebugLog
    private int add(int a, int b) {

        return a + b;

    }



输出:

08-25 14:52:43.413 26165-26165/test.xl.com.myapplication V/MainActivity: ⇢ onCreate(savedInstanceState=null)
08-25 14:52:43.490 26165-26165/test.xl.com.myapplication V/MainActivity: ⇢ add(a=1, b=8)
08-25 14:52:43.490 26165-26165/test.xl.com.myapplication V/MainActivity: ⇠ add [0ms] = 9
08-25 14:52:43.490 26165-26165/test.xl.com.myapplication V/MainActivity: ⇠ onCreate [76ms]


 

2. Stetho

项目地址:https://github.com/facebook/stetho

 

通过Elements标签查看界面的视图结构。
通过Network标签观察网络请求。
通过Resources标签查看本地数据,比如sqlite数据库,sharepreference等等。同时可以在这里执行sql语句。
通过Console标签,在这里执行js语句,可以在APP上弹出一个Toast。
dumpapp 是linux/mac上使用的命令行工具,可以修改app内部资源,暂时未详细了解。

 

项目build.gradle

dependencies {
    compile 'com.facebook.stetho:stetho:1.5.0'
    compile 'com.facebook.stetho:stetho-okhttp3:1.5.0'
}


初始化Stetho:

public class MyApplication extends Application {

    @Override
    public void onCreate() {
        super.onCreate();
        Stetho.initializeWithDefaults(this);
    }


使用:1. 运行工程,在chrom浏览器中输入:

chrome://inspect

è¿éåå¾çæè¿°

点击inspect 

è¿éåå¾çæè¿°

例子:查询存储的SP信息

 

 SharedPreferences sp = getSharedPreferences("test", Context.MODE_PRIVATE);
  SharedPreferences.Editor editor = sp.edit();
  editor.putString("name", "xiaoming");
  editor.putInt("age", 20);
  editor.putString("sex", "男");
  editor.commit();



stetho显示结果: 

è¿éåå¾çæè¿°
Logger

项目地址:https://github.com/orhanobut/logger

 

Logger 提供以下功能:

  • 线程的信息
  • 类的信息
  • 方法的信息
  • 将 JSON 文本人性化输出
  • 将换行符人性化输出
  • 简洁的输出
  • 从日志跳转到源码

 

项目build.grader

compile 'com.orhanobut:logger:2.1.1'


 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值