Junit3断言
在Robotium自动化测试的过程中,发现没有断言的脚本是没有意义的,现整理Junit3和Junit4的断言,供日后查阅。
http://junit.org/
Junit3断言API:
http://www.cs.rice.edu/~javaplt/javadoc/junit3.8.2/junit/framework/Assert.html
Constructor Summary | |
protected |
Assert() Protect constructor since it is a static only class |
Method Summary | |
static void |
assertEquals(boolean expected, boolean actual) Asserts that two booleans are equal. |
static void |
assertEquals(byte expected, byte actual) Asserts that two bytes are equal. |
static void |
assertEquals(char expected, char actual) Asserts that two chars are equal. |
static void |
assertEquals(double expected, double actual, double delta) Asserts that two doubles are equal concerning a delta. |
static void |
assertEquals(float expected, float actual, float delta) Asserts that two floats are equal concerning a delta. |
static void |
assertEquals(int expected, int actual) Asserts that two ints are equal. |
static void |
assertEquals(long expected, long actual) Asserts that two longs are equal. |
static void |
assertEquals(java.lang.Object expected, java.lang.Object actual) Asserts that two objects are equal. |
static void |
assertEquals(short expected, short actual) Asserts that two shorts are equal. |
static void |
assertEquals(java.lang.String message, boolean expected, boolean actual) Asserts that two booleans are equal. |
static void |
assertEquals(java.lang.String message, byte expected, byte actual) Asserts that two bytes are equal. |
static void |
assertEquals(java.lang.String message, char expected, char actual) Asserts that two chars are equal. |
static void |
assertEquals(java.lang.String message, double expected, double actual, double delta) Asserts that two doubles are equal concerning a delta. |
static void |
assertEquals(java.lang.String message, float expected, float actual, float delta) Asserts that two floats are equal concerning a delta. |
static void |
assertEquals(java.lang.String message, int expected, int actual) Asserts that two ints are equal. |
static void |
assertEquals(java.lang.String message, long expected, long actual) Asserts that two longs are equal. |
static void |
assertEquals(java.lang.String message, java.lang.Object expected, java.lang.Object actual) Asserts that two objects are equal. |
static void |
assertEquals(java.lang.String message, short expected, short actual) Asserts that two shorts are equal. |
static void |
assertEquals(java.lang.String expected, java.lang.String actual) Asserts that two Strings are equal. |
static void |
assertEquals(java.lang.String message, java.lang.String expected, java.lang.String actual) Asserts that two Strings are equal. |
static void |
assertFalse(boolean condition) Asserts that a condition is false. |
static void |
assertFalse(java.lang.String message, boolean condition) Asserts that a condition is false. |
static void |
assertNotNull(java.lang.Object object) Asserts that an object isn't null. |
static void |
assertNotNull(java.lang.String message, java.lang.Object object) Asserts that an object isn't null. |
static void |
assertNotSame(java.lang.Object expected, java.lang.Object actual) Asserts that two objects do not refer to the same object. |
static void |
assertNotSame(java.lang.String message, java.lang.Object expected, java.lang.Object actual) Asserts that two objects do not refer to the same object. |
static void |
assertNull(java.lang.Object object) Asserts that an object is null. |
static void |
assertNull(java.lang.String message, java.lang.Object object) Asserts that an object is null. |
static void |
assertSame(java.lang.Object expected, java.lang.Object actual) Asserts that two objects refer to the same object. |
static void |
assertSame(java.lang.String message, java.lang.Object expected, java.lang.Object actual) Asserts that two objects refer to the same object. |
static void |
assertTrue(boolean condition) Asserts that a condition is true. |
static void |
assertTrue(java.lang.String message, boolean condition) Asserts that a condition is true. |
static void |
fail() Fails a test with no message. |
static void |
fail(java.lang.String message) Fails a test with the given message. |
static void |
failNotEquals(java.lang.String message, java.lang.Object expected, java.lang.Object actual) |
static void |
failNotSame(java.lang.String message, java.lang.Object expected, java.lang.Object actual) |
static void |
failSame(java.lang.String message) |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
Assert
protected Assert()
- Protect constructor since it is a static only class
Method Detail |
assertTrue
public static void assertTrue(java.lang.String message,
boolean condition)
- Asserts that a condition is true. If it isn't it throws an AssertionFailedError with the given message.
-
assertTrue
public static void assertTrue(boolean condition)
- Asserts that a condition is true. If it isn't it throws an AssertionFailedError.
-
assertFalse
public static void assertFalse(java.lang.String message,
boolean condition)
- Asserts that a condition is false. If it isn't it throws an AssertionFailedError with the given message.
-
assertFalse
public static void assertFalse(boolean condition)
- Asserts that a condition is false. If it isn't it throws an AssertionFailedError.
-
fail
public static void fail(java.lang.String message)
- Fails a test with the given message.
-
fail
public static void fail()
- Fails a test with no message.
-
assertEquals
public static void assertEquals(java.lang.String message,
java.lang.Object expected,
java.lang.Object actual)
- Asserts that two objects are equal. If they are not an AssertionFailedError is thrown with the given message.
-
assertEquals
public static void assertEquals(java.lang.Object expected,
java.lang.Object actual)
- Asserts that two objects are equal. If they are not an AssertionFailedError is thrown.
-
assertEquals
public static void assertEquals(java.lang.String message,
java.lang.String expected,
java.lang.String actual)
- Asserts that two Strings are equal.
-
assertEquals
public static void assertEquals(java.lang.String expected,
java.lang.String actual)
- Asserts that two Strings are equal.
-
assertEquals
public static void assertEquals(java.lang.String message,
double expected,
double actual,
double delta)
- Asserts that two doubles are equal concerning a delta. If they are not an AssertionFailedError is thrown with the given message. If the expected value is infinity then the delta value is ignored.
-
assertEquals
public static void assertEquals(double expected,
double actual,
double delta)
- Asserts that two doubles are equal concerning a delta. If the expected value is infinity then the delta value is ignored.
-
assertEquals
public static void assertEquals(java.lang.String message,
float expected,
float actual,
float delta)
- Asserts that two floats are equal concerning a delta. If they are not an AssertionFailedError is thrown with the given message. If the expected value is infinity then the delta value is ignored.
-
assertEquals
public static void assertEquals(float expected,
float actual,
float delta)
- Asserts that two floats are equal concerning a delta. If the expected value is infinity then the delta value is ignored.
-
assertEquals
public static void assertEquals(java.lang.String message,
long expected,
long actual)
- Asserts that two longs are equal. If they are not an AssertionFailedError is thrown with the given message.
-
assertEquals
public static void assertEquals(long expected,
long actual)
- Asserts that two longs are equal.
-
assertEquals
public static void assertEquals(java.lang.String message,
boolean expected,
boolean actual)
- Asserts that two booleans are equal. If they are not an AssertionFailedError is thrown with the given message.
-
assertEquals
public static void assertEquals(boolean expected,
boolean actual)
- Asserts that two booleans are equal.
-
assertEquals
public static void assertEquals(java.lang.String message,
byte expected,
byte actual)
- Asserts that two bytes are equal. If they are not an AssertionFailedError is thrown with the given message.
-
assertEquals
public static void assertEquals(byte expected,
byte actual)
- Asserts that two bytes are equal.
-
assertEquals
public static void assertEquals(java.lang.String message,
char expected,
char actual)
- Asserts that two chars are equal. If they are not an AssertionFailedError is thrown with the given message.
-
assertEquals
public static void assertEquals(char expected,
char actual)
- Asserts that two chars are equal.
-
assertEquals
public static void assertEquals(java.lang.String message,
short expected,
short actual)
- Asserts that two shorts are equal. If they are not an AssertionFailedError is thrown with the given message.
-
assertEquals
public static void assertEquals(short expected,
short actual)
- Asserts that two shorts are equal.
-
assertEquals
public static void assertEquals(java.lang.String message,
int expected,
int actual)
- Asserts that two ints are equal. If they are not an AssertionFailedError is thrown with the given message.
-
assertEquals
public static void assertEquals(int expected,
int actual)
- Asserts that two ints are equal.
-
assertNotNull
public static void assertNotNull(java.lang.Object object)
- Asserts that an object isn't null.
-
assertNotNull
public static void assertNotNull(java.lang.String message,
java.lang.Object object)
- Asserts that an object isn't null. If it is an AssertionFailedError is thrown with the given message.
-
assertNull
public static void assertNull(java.lang.Object object)
- Asserts that an object is null.
-
assertNull
public static void assertNull(java.lang.String message,
java.lang.Object object)
- Asserts that an object is null. If it is not an AssertionFailedError is thrown with the given message.
-
assertSame
public static void assertSame(java.lang.String message,
java.lang.Object expected,
java.lang.Object actual)
- Asserts that two objects refer to the same object. If they are not an AssertionFailedError is thrown with the given message.
-
assertSame
public static void assertSame(java.lang.Object expected,
java.lang.Object actual)
- Asserts that two objects refer to the same object. If they are not the same an AssertionFailedError is thrown.
-
assertNotSame
public static void assertNotSame(java.lang.String message,
java.lang.Object expected,
java.lang.Object actual)
- Asserts that two objects do not refer to the same object. If they do refer to the same object an AssertionFailedError is thrown with the given message.
-
assertNotSame
public static void assertNotSame(java.lang.Object expected,
java.lang.Object actual)
- Asserts that two objects do not refer to the same object. If they do refer to the same object an AssertionFailedError is thrown.
-
failSame
public static void failSame(java.lang.String message)
failNotSame
public static void failNotSame(java.lang.String message,
java.lang.Object expected,
java.lang.Object actual)
failNotEquals
public static void failNotEquals(java.lang.String message,
java.lang.Object expected,
java.lang.Object actual)
Junit3断言的更多相关文章
- Junit3与Junit4的区别
Junit4最大的亮点就是引入了注解(annotation),通过解析注解就可以为测试提供相应的信息,抛弃junit3使用命名约束以及反射机制的方法. /** * 被测试类 */ package co ...
- junit3对比junit4
本文内容摘自junit实战,感谢作者的无私奉献. 个人觉得每个开源包的版本对比意义不大,闲来无事,这里就来整理一下好了.本文名为junit3对比junit4,但是我通过这篇博客主要也是想统一的来整理下 ...
- junit3和junit4的使用区别如下
junit3和junit4的使用区别如下1.在JUnit3中需要继承TestCase类,但在JUnit4中已经不需要继承TestCase2.在JUnit3中需要覆盖TestCase中的setUp和te ...
- junit 常用注解 + junit 断言详解
@Test: 在junit3中,是通过对测试类和测试方法的命名来确定是否是测试,且所有的测试类必须继承junit的测试基类.在junit4中,定义一个测试方法变得简单很多,只需要在方法前加上@Test ...
- junit基础学习之-junit3和4的区别(4)
junit3和junit4的使用区别如下 1.在JUnit3中需要继承TestCase类,但在JUnit4中已经不需要继承TestCase 2.在JUnit3中需要覆盖TestCase中的setUp和 ...
- 记一个mvn奇怪错误: Archive for required library: 'D:/mvn/repos/junit/junit/3.8.1/junit-3.8.1.jar' in project 'xxx' cannot be read or is not a valid ZIP file
我的maven 项目有一个红色感叹号, 而且Problems 存在 errors : Description Resource Path Location Type Archive for requi ...
- iOS-----程序异常处理----- 断言NSAssert()和NSParameterAssert区别和用处
NSAssert和assert是断言,主要的差别是assert在断言失败的时候只是简单的终止程序,而NSAssert会报告出错误信息并且打印出来.所以尽管的使用NSAssert,可以不去使用asser ...
- GO语言总结(5)——类型转换和类型断言
上一篇博客介绍了Go语言的数组和切片——GO语言总结(4)——映射(Map),本篇博客介绍Go语言的类型转换和类型断言 由于Go语言不允许隐式类型转换.而类型转换和类型断言的本质,就是把一个类型转换到 ...
- postman 断言解析
最近在学习postman官方文档, 顺势翻译出来,以供学习! postman断言是JavaScript语言编写的,在postman客户端指定区域编写即可. 断言会在请求返回之后,运行,并根据断言的pa ...
随机推荐
- PS中的图像知识
图像处理对于前端工作来说是一个不能回避的问题,ps技术也是我们必备的技能.用法可以在使用中不断的熟练,但针对前端技术本身的一些知识点,需要我们平时不断的积累才能够在使用中不出现问题. 如今的办公,已经 ...
- Find Median from Data Stream
常规方法 超时 class MedianFinder { vector<int> coll; public: MedianFinder(){ } void heapfu(vector< ...
- js 测试
今天js测试题目: 被基础题目虐暴......惨不忍睹 1. var num = 2; switch(num){ case 1: console.log("1"); case 2: ...
- malloc原理和内存碎片[转]
当一个进程发生缺页中断的时候,进程会陷入内核态,执行以下操作: 1.检查要访问的虚拟地址是否合法 2.查找/分配一个物理页 3.填充物理页内容(读取磁盘,或者直接置0,或者啥也不干) 4.建立映射关系 ...
- MAC的终端命令
今天小研究了一下MAC的终端命令,主要为了方便调试程序用,XCODE用不来啊... 在这里记下..防止丢失 pwd 当前工作目录 cd(不加参数) 进root cd(folder) 进入文件夹 cd ...
- C++ 取得系统当前时间
#include <time.h> //* 方法一 time_t tt = time(NULL);//这句返回的只是一个时间cuo tm* t= localtime(&tt); p ...
- varnish 4.0.3 域名访问的小问题
1,若端口不是80 端口则匹配的时候必须加端口 if (req.http.host ~ "(?i)^var.test.aa:6081$") {set req.http.host = ...
- java 事件监听 - 键盘
java 事件监听 - 键盘 //事件监听 //键盘事件监听,写了一个小案例,按上下左右,改变圆形的位置,圆形可以移动 import java.awt.*; import javax.swing.*; ...
- jquery mobile 登陆后页面验证
调用 pagebeforechange方法 $(document).bind("pagebeforechange", function (e, data) { if (typeof ...
- APP UI设计及切图规范
APP UI设计及切图规范 1.概述 1.1 编写目的 该文档主要针对移动端开发的视觉设计和开发过程中的工作环节做统一的规划规范,是系统进入UI设计的前置文档.部分内容来自网络收集修编,转载请注明由 ...