iis服务器助手广告广告
返回顶部
首页 > 资讯 > 移动开发 >Android中使用自身携带的Junit新建一个测试工程
  • 135
分享到

Android中使用自身携带的Junit新建一个测试工程

工程junit测试Android 2022-06-06 12:06:03 135人浏览 安东尼
摘要

  1、新建立一个Android工程 package com.shellway.junit; public class Ser

  1、新建立一个Android工程

package com.shellway.junit; public class Service { public int divide(int a,int b){ return a/b; } } package com.shellway.junit; import junit.framework.Assert; import android.test.AndroidTestCase; public class TestT extends AndroidTestCase { public void test1(){ Service service = new Service(); System.out.println(service.divide(10, 2)); } public void test2(){ Service service = new Service(); System.out.println(service.divide(10, 0)); } public void test3(){ Service service = new Service(); Assert.assertEquals(2.5, service.divide(10, 4)); } } <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="Http://schemas.android.com/apk/res/android" package="com.shellway.junit" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="16" android:targetSdkVersion="21" /> <instrumentation android:targetPackage="com.shellway.junit" android:name="android.test.InstrumentationTestRunner" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <uses-library android:name="android.test.runner" /> <activity android:name=".MainActivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <cateGory android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest>


--结束END--

本文标题: Android中使用自身携带的Junit新建一个测试工程

本文链接: https://www.lsjlt.com/news/28731.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作