zoukankan      html  css  js  c++  java
  • 单元测试在android中的应用

    在实际开发中,开发android软件的过程需要不断进行测试。使用Junit测试框架,是正规android开发的必要条件。

    第一步: 在Androidmanifest.xml中加入下面红色代码

    <manifest xmlns:android="http://schemas.android.com/apk/res/android"

    package="cn.itcast.action“ android:versionCode="1“ android:versionName="1.0">

    <application android:icon="@drawable/icon" android:label="@string/app_name">

    <uses-library android:name="android.test.runner" />

    ....

    </application>

    <uses-sdk android:minSdkVersion="6" />

    <instrumentation android:name="android.test.InstrumentationTestRunner"

    android:targetPackage="cn.itcast.action" android:label="Tests for My App" />

    </manifest>

    上面targetPackage指定的包要和应用的package相同。

    第二步: 编写单元测试代码,选择要测试的方法,右键点击“Run As”--“Android Junit Test” ):

    import android.test.AndroidTestCase;

    import android.util.Log;

    public class XMLTest extends AndroidTestCase {

    public void testSomething() throws Throwable {

    Assert.assertTrue(1 + 1 == 3);

    }

    }

  • 相关阅读:
    ELK搭建
    php 高效日志记录扩展seaslog 的使用
    linux批量修改文件中包含字符串的查找替换
    goaccess
    mysql启动错误,提示crash 错误
    laravel config 配置无效
    地址重写 No input file specified的解决方法
    redis 一些操作命令
    RNN与LSTM
    最大熵推导LR
  • 原文地址:https://www.cnblogs.com/xitang/p/2163857.html
Copyright © 2011-2022 走看看