在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断言的更多相关文章

  1. Junit3与Junit4的区别

    Junit4最大的亮点就是引入了注解(annotation),通过解析注解就可以为测试提供相应的信息,抛弃junit3使用命名约束以及反射机制的方法. /** * 被测试类 */ package co ...

  2. junit3对比junit4

    本文内容摘自junit实战,感谢作者的无私奉献. 个人觉得每个开源包的版本对比意义不大,闲来无事,这里就来整理一下好了.本文名为junit3对比junit4,但是我通过这篇博客主要也是想统一的来整理下 ...

  3. junit3和junit4的使用区别如下

    junit3和junit4的使用区别如下1.在JUnit3中需要继承TestCase类,但在JUnit4中已经不需要继承TestCase2.在JUnit3中需要覆盖TestCase中的setUp和te ...

  4. junit 常用注解 + junit 断言详解

    @Test: 在junit3中,是通过对测试类和测试方法的命名来确定是否是测试,且所有的测试类必须继承junit的测试基类.在junit4中,定义一个测试方法变得简单很多,只需要在方法前加上@Test ...

  5. junit基础学习之-junit3和4的区别(4)

    junit3和junit4的使用区别如下 1.在JUnit3中需要继承TestCase类,但在JUnit4中已经不需要继承TestCase 2.在JUnit3中需要覆盖TestCase中的setUp和 ...

  6. 记一个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 ...

  7. iOS-----程序异常处理----- 断言NSAssert()和NSParameterAssert区别和用处

    NSAssert和assert是断言,主要的差别是assert在断言失败的时候只是简单的终止程序,而NSAssert会报告出错误信息并且打印出来.所以尽管的使用NSAssert,可以不去使用asser ...

  8. GO语言总结(5)——类型转换和类型断言

    上一篇博客介绍了Go语言的数组和切片——GO语言总结(4)——映射(Map),本篇博客介绍Go语言的类型转换和类型断言 由于Go语言不允许隐式类型转换.而类型转换和类型断言的本质,就是把一个类型转换到 ...

  9. postman 断言解析

    最近在学习postman官方文档, 顺势翻译出来,以供学习! postman断言是JavaScript语言编写的,在postman客户端指定区域编写即可. 断言会在请求返回之后,运行,并根据断言的pa ...

随机推荐

  1. java中文乱码分析整理

    在JavaWeb应用开发中,经常会出现页面中本该显示中文的地方却是乱码的情况.究其原因,主要是由于在Web组件之间.或Web组件与浏览器.与数据库所使用的字符集标准不统一,Web应用程序运行过程中,中 ...

  2. Windows快速删除文件脚本

    1.新建一个txt文件 2.将DEL /F /A /Q \\?\%1RD /S /Q \\?\%1这段代码放在新建好的txt文件中 3.将txt文件的后缀名改为.bat 4.将这个文件放在需要删除的文 ...

  3. android studio入门

    目前的工作是蓝牙相关的,所以最近心血来潮想折腾下Android开发,方便调试自己的固件, 装好Android Studio跟SDK之后,感谢nordic的公开代码,研究了一会,感觉并没有多费劲 相关的 ...

  4. oracle单机改变归档路径

    oracle 归档日志文件路径设置 1.  查看LOG_ARCHIVE_DEST 与 ( LOG_ARCHIVE_DEST_n 或 DB_RECOVERY_FILE_DEST )参数情况注意(  LO ...

  5. HttpModule & HttpHandler

    ASP.NET 处理请求的过程 inetinfo.exe:www 服务进程,IIS 服务 和 ASPNET_ISAPI.dll 都寄存在此进程中. ASPNET_ISAPI.dll:处理 .aspx ...

  6. windows脚本调用批处理

    set ws=wscript.createobject(“wscript.shell”)ws.run “batchfn.bat /start”,0 save as xxx.vbe file.

  7. css预处理语言的模块化实践

    编写css是前端工作中,一项普通而又频繁的劳动,由于css并不是一门语言,所以在程序设计上显得有些简陋.对于小型项目来说,css的量还不至于庞大,问题没有凸显,而如果要开发和持续维护一个较为大型的项目 ...

  8. C++ 数字转字符串

    #include <sstream> string num2str( int i) { stringstream ss; ss<<i; return ss.strs(); }

  9. javascript生成对象的三种方法

    /** js生成对象的三种方法*/ // 1.通过new Object,然后添加属性 示例如下: var people1 = new Object(); people1.name = 'xiaohai ...

  10. Using dojo/query(翻译)

    In this tutorial, we will learn about DOM querying and how the dojo/query module allows you to easil ...