Giter VIP home page Giter VIP logo

androidemma's Introduction

AndroidEmma

项目参考TestHome 里面手工测试代码覆盖率手工版,只为提供一种方便大家调用的工具,和当前项目无侵入。

参考信息

#使用方法

  • 在app/src目录下面建立debug目录,AndroidManifest.xml 文件信息如下
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="替换成自己的包名">

    <instrumentation
        android:handleProfiling="true"
        android:label="CoverageInstrumentation"
        android:name="me.shenfan.androidemma.EmmaInstrumentation"
        android:targetPackage="替换成自己的包名"/>

</manifest>

在app下面的build.gradle中添加

apply plugin: 'jacoco'
jacoco{
    toolVersion = "0.7.1.201405082137"
}

android{
    buildTypes {
        debug {
            testCoverageEnabled = true
        }   
    }
}

dump覆盖率文件的俩种方式:

  • 一: 主界面的Activity实现接口 EmmaInstrumentationListener, 添加如下方法,会在程序退出的时候dump测试覆盖率
    private FinishListener finishListener;

    @Override
    public void setFinishListener(FinishListener listener) {
        finishListener = listener;
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        if (finishListener != null){
            finishListener.onActivityFinished();
        }
    }
  • 二: 在需要的时候调用下面方法
   EmmaUtil.dump(Context);

更多信息见demo项目

开始手工测试

打开桌面图标 EmmaInstrumentation ,点击 open即可,其实就是执行了

adb shell am instrument 当前应用包名/me.shenfan.androidemma.EmmaInstrumentation

覆盖率结果查看

默认数据保存在 sdcard/Android/当前项目包名/coverage.ec

根据coverage.ec 生成报告,请看这里

Gradle

allprojects {
    repositories {
        maven { url "https://www.jitpack.io" }
    }
}

dependencies {
    debugCompile  'com.github.yaming116.AndroidEmma:library:1.1.0'
    releaseCompile 'com.github.yaming116.AndroidEmma:androidemma-no-op:1.1.0'
}

License

Copyright (C) 2011 花开堪折枝 Software Ltd

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

androidemma's People

Contributors

yaming116 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.