Junit
来源:互联网 发布:北京网络职业学院贴吧 编辑:程序博客网 时间:2024/06/03 17:11
JUnit是一个Java语言的单元测试框架。它由Kent Beck和Erich Gamma建立,逐渐成为源于Kent Beck的sUnit的xUnit家族中最为成功的一个。 JUnit有它自己的JUnit扩展生态圈。多数Java的开发环境都已经集成了JUnit作为单元测试的工具。
JUnit是由 Erich Gamma 和 Kent Beck 编写的一个回归测试框架(regression testing framework)。Junit测试是程序员测试,即所谓白盒测试,因为程序员知道被测试的软件如何(How)完成功能和完成什么样(What)的功能。Junit是一套框架,继承TestCase类,就可以用Junit进行自动测试了。
回归测试是指修改了旧代码后,重新进行测试以确认修改没有引入新的错误或导致其他代码产生错误。自动回归测试将大幅降低系统测试、维护升级等阶段的成本。回归测试作为软件生命周期的一个组成部分,在整个软件测试过程中占有很大的工作量比重,软件开发的各个阶段都会进行多次回归测试。在渐进和快速迭代开发中,新版本的连续发布使回归测试进行的更加频繁,而在极端编程方法中,更是要求每天都进行若干次回归测试。因此,通过选择正确的回归测试策略来改进回归测试的效率和有效性是非常有意义的。
Android Testing
android里面的的单元测试本质上和junit差不多,先来看一下例子:android sdk sample snake的测试(导入的时候test报sdk version 最低是8现在是1 错误,直接project->Android Tools->clear link marks)
首先是menifest.xml文件
1 在application tag中指明我们需要android.test库包,构建测试用例的时候需要用到它
2 <instrumentation> 标签 android:name 、android:targetPackage android:lable
<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.android.snake.tests"> <!-- We add an application tag here just so that we can indicate that this package needs to link against the android.test library, which is needed when building test cases. --> <application> <uses-library android:name="android.test.runner" /> </application> <instrumentation android:name="android.test.InstrumentationTestRunner" android:targetPackage="com.example.android.snake" android:label="Snake sample tests"> </instrumentation> </manifest>
package com.example.android.snake;import android.test.ActivityInstrumentationTestCase2;/** * Make sure that the main launcher activity opens up properly, which will be * verified by {@link #testActivityTestCaseSetUpProperly}. */public class SnakeTest extends ActivityInstrumentationTestCase2<Snake> { /** * Creates an {@link ActivityInstrumentationTestCase2} for the {@link Snake} activity. */ public SnakeTest() { super(Snake.class); } /** * Verifies that the activity under test can be launched. */ public void testActivityTestCaseSetUpProperly() { assertNotNull("activity should be launched successfully", getActivity()); }}
参考:http://blog.csdn.net/wangpeng047/article/details/9628449
- JUNIT
- junit
- Junit
- JUnit
- JUnit
- JUnit
- JUNIT
- junit
- Junit
- JUnit
- Junit
- JUnit
- Junit
- Junit
- JUnit
- junit
- junit
- JUnit
- JDK获取父类的方法
- SharePoint 2013 搜索报错"Unable to retrieve topology component health. This may be because the admin com
- RabbitMQ概念及环境搭建(一)单节点安装与配置
- 为什么总是“需求”在前面
- BZOJ 2348 Baltic 2011 Plagiarism 排序
- Junit
- CPU寄存器
- android编程之代码布局
- 再说 c++11 内存模型
- 9.4.2.2 F# 中的向上转换和向下转换(UPCASTS AND DOWNCASTS)
- C#和android 端互通 RSA算法 解决不能私钥解密问题。
- Android刷机脚本——updater-script
- c# 判断当前网络是否可用
- Linux系统启动过程