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 ...
随机推荐
- Geolocation API 原理及方法
使用IP地址:基于Web的数据库:无线网络连接定位:三角测量:GPS技术:来测量经度和纬度.(综合了所有技术)地理定位的精确度,有很多方法可以定位用户的地理位置,并且每种方法都有不同的精度.桌面浏览器 ...
- Mongodb优化
本文将从各个层面讲述Mongodb的优化方法
- Android手机录制视频 实时传输(转载)
最近调研android视频录制.另一部手机实时观看,大致有以下几种思路. 1. android手机充当服务器,使用NanoHTTPD充当服务器,另一部手机或者pc通过输入http://手机的ip:80 ...
- 一些对新手有用的css技巧
一.表单部分 1.禁止textarea文本域的缩放 resize:none; 2.去除初始化textarea下拉条 overflow:auto; 3.如何让表单中的选项按钮,点击文字也能选中? < ...
- warning 4510 with const member in struct
I write a code section as this struct My{const int a;}; OK, then set the warning level then I will g ...
- Servlet 3.0 异步模式
Servlet 3.0标准新增了异步处理的支持. 进行异步处理的Servlet和作用于该Servlet的拦截器都必须声明对于异步处理的支持.
- JSON.parse() 和 JSON.stringify()
JSON.parse()和JSON.stringify() 1.parse 用于从一个字符串中解析出json 对象.例如 var str='{"name":"cpf& ...
- 作业三:WC项目
WC一个简单的文件检测系统 用c语言实现 不多说 上代码 #include<stdio.h> #include<stdlib.h> #include <io.h> ...
- c# 映射对比测试
c# 映射对比测试(测试对象,测试案例,测试结果) 测试组件对象: TinyMapper-EmitMapper-AutoMapper-NLiteMapper-Handwritten 对比测试案例: ...
- JavaScript 表单验证
长度限制: <script>function test(){if(document.a.b.value.length>50){alert("不能超过50个字符!" ...