Junit4断言

时间:2021-11-18 01:23:32

Junit4断言API:

http://junit.org/javadoc/latest/index.html

Constructor Summary
protected Assert() 
          Protect constructor since it is a static only class
Method Summary
static void assertArrayEquals(boolean[] expecteds, boolean[] actuals) 
          Asserts that two boolean arrays are equal.
static void assertArrayEquals(byte[] expecteds, byte[] actuals) 
          Asserts that two byte arrays are equal.
static void assertArrayEquals(char[] expecteds, char[] actuals) 
          Asserts that two char arrays are equal.
static void assertArrayEquals(double[] expecteds, double[] actuals, double delta) 
          Asserts that two double arrays are equal.
static void assertArrayEquals(float[] expecteds, float[] actuals, float delta) 
          Asserts that two float arrays are equal.
static void assertArrayEquals(int[] expecteds, int[] actuals) 
          Asserts that two int arrays are equal.
static void assertArrayEquals(long[] expecteds, long[] actuals) 
          Asserts that two long arrays are equal.
static void assertArrayEquals(Object[] expecteds, Object[] actuals) 
          Asserts that two object arrays are equal.
static void assertArrayEquals(short[] expecteds, short[] actuals) 
          Asserts that two short arrays are equal.
static void assertArrayEquals(String message, boolean[] expecteds, boolean[] actuals) 
          Asserts that two boolean arrays are equal.
static void assertArrayEquals(String message, byte[] expecteds, byte[] actuals) 
          Asserts that two byte arrays are equal.
static void assertArrayEquals(String message, char[] expecteds, char[] actuals) 
          Asserts that two char arrays are equal.
static void assertArrayEquals(String message, double[] expecteds, double[] actuals, double delta) 
          Asserts that two double arrays are equal.
static void assertArrayEquals(String message, float[] expecteds, float[] actuals, float delta) 
          Asserts that two float arrays are equal.
static void assertArrayEquals(String message, int[] expecteds, int[] actuals) 
          Asserts that two int arrays are equal.
static void assertArrayEquals(String message, long[] expecteds, long[] actuals) 
          Asserts that two long arrays are equal.
static void assertArrayEquals(String message, Object[] expecteds, Object[] actuals) 
          Asserts that two object arrays are equal.
static void assertArrayEquals(String message, short[] expecteds, short[] actuals) 
          Asserts that two short arrays are equal.
static void assertEquals(double expected, double actual) 
          Deprecated. Use assertEquals(double expected, double actual, double delta) instead
static void assertEquals(double expected, double actual, double delta) 
          Asserts that two doubles are equal to within a positive delta.
static void assertEquals(float expected, float actual, float delta) 
          Asserts that two floats are equal to within a positive delta.
static void assertEquals(long expected, long actual) 
          Asserts that two longs are equal.
static void assertEquals(Object[] expecteds, Object[] actuals) 
          Deprecated. use assertArrayEquals
static void assertEquals(Object expected, Object actual) 
          Asserts that two objects are equal.
static void assertEquals(String message, double expected, double actual) 
          Deprecated. Use assertEquals(String message, double expected, double actual, double delta) instead
static void assertEquals(String message, double expected, double actual, double delta) 
          Asserts that two doubles are equal to within a positive delta.
static void assertEquals(String message, float expected, float actual, float delta) 
          Asserts that two floats are equal to within a positive delta.
static void assertEquals(String message, long expected, long actual) 
          Asserts that two longs are equal.
static void assertEquals(String message, Object[] expecteds, Object[] actuals) 
          Deprecated. use assertArrayEquals
static void assertEquals(String message, Object expected, Object actual) 
          Asserts that two objects are equal.
static void assertFalse(boolean condition) 
          Asserts that a condition is false.
static void assertFalse(String message, boolean condition) 
          Asserts that a condition is false.
static void assertNotEquals(double unexpected, double actual, double delta) 
          Asserts that two doubles are not equal to within a positive delta.
static void assertNotEquals(float unexpected, float actual, float delta) 
          Asserts that two floats are not equal to within a positive delta.
static void assertNotEquals(long unexpected, long actual) 
          Asserts that two longs are not equals.
static void assertNotEquals(Object unexpected, Object actual) 
          Asserts that two objects are not equals.
static void assertNotEquals(String message, double unexpected, double actual, double delta) 
          Asserts that two doubles are not equal to within a positive delta.
static void assertNotEquals(String message, float unexpected, float actual, float delta) 
          Asserts that two floats are not equal to within a positive delta.
static void assertNotEquals(String message, long unexpected, long actual) 
          Asserts that two longs are not equals.
static void assertNotEquals(String message, Object unexpected, Object actual) 
          Asserts that two objects are not equals.
static void assertNotNull(Object object) 
          Asserts that an object isn't null.
static void assertNotNull(String message, Object object) 
          Asserts that an object isn't null.
static void assertNotSame(Object unexpected, Object actual) 
          Asserts that two objects do not refer to the same object.
static void assertNotSame(String message, Object unexpected, Object actual) 
          Asserts that two objects do not refer to the same object.
static void assertNull(Object object) 
          Asserts that an object is null.
static void assertNull(String message, Object object) 
          Asserts that an object is null.
static void assertSame(Object expected, Object actual) 
          Asserts that two objects refer to the same object.
static void assertSame(String message, Object expected, Object actual) 
          Asserts that two objects refer to the same object.
static
<T> void
assertThat(String reason, T actual, Matcher<? super T> matcher) 
          Asserts that actual satisfies the condition specified by matcher.
static
<T> void
assertThat(T actual, Matcher<? super T> matcher) 
          Asserts that actual satisfies the condition specified by matcher.
static void assertTrue(boolean condition) 
          Asserts that a condition is true.
static void assertTrue(String message, boolean condition) 
          Asserts that a condition is true.
static void fail() 
          Fails a test with no message.
static void fail(String message) 
          Fails a test with the given message.
Methods inherited from class java.lang.Object
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait
Constructor Detail

Assert

protected Assert()
Protect constructor since it is a static only class
Method Detail

assertTrue

public static void assertTrue(String message,
boolean condition)
Asserts that a condition is true. If it isn't it throws an AssertionError with the given message.
Parameters:
message - the identifying message for the AssertionError (null okay)
condition - condition to be checked

assertTrue

public static void assertTrue(boolean condition)
Asserts that a condition is true. If it isn't it throws an AssertionError without a message.
Parameters:
condition - condition to be checked

assertFalse

public static void assertFalse(String message,
boolean condition)
Asserts that a condition is false. If it isn't it throws an AssertionError with the given message.
Parameters:
message - the identifying message for the AssertionError (null okay)
condition - condition to be checked

assertFalse

public static void assertFalse(boolean condition)
Asserts that a condition is false. If it isn't it throws an AssertionError without a message.
Parameters:
condition - condition to be checked

fail

public static void fail(String message)
Fails a test with the given message.
Parameters:
message - the identifying message for the AssertionError (null okay)
See Also:
AssertionError

fail

public static void fail()
Fails a test with no message.

assertEquals

public static void assertEquals(String message,
Object expected,
Object actual)
Asserts that two objects are equal. If they are not, an AssertionError is thrown with the given message. If expected and actual are null, they are considered equal.
Parameters:
message - the identifying message for the AssertionError (null okay)
expected - expected value
actual - actual value

assertEquals

public static void assertEquals(Object expected,
Object actual)
Asserts that two objects are equal. If they are not, an AssertionError without a message is thrown. If expected and actual are null, they are considered equal.
Parameters:
expected - expected value
actual - the value to check against expected

assertNotEquals

public static void assertNotEquals(String message,
Object unexpected,
Object actual)
Asserts that two objects are not equals. If they are, an AssertionError is thrown with the given message. If unexpected and actual are null, they are considered equal.
Parameters:
message - the identifying message for the AssertionError (null okay)
unexpected - unexpected value to check
actual - the value to check against unexpected

assertNotEquals

public static void assertNotEquals(Object unexpected,
Object actual)
Asserts that two objects are not equals. If they are, an AssertionError without a message is thrown. If unexpected and actual are null, they are considered equal.
Parameters:
unexpected - unexpected value to check
actual - the value to check against unexpected

assertNotEquals

public static void assertNotEquals(String message,
long unexpected,
long actual)
Asserts that two longs are not equals. If they are, an AssertionError is thrown with the given message.
Parameters:
message - the identifying message for the AssertionError (null okay)
unexpected - unexpected value to check
actual - the value to check against unexpected

assertNotEquals

public static void assertNotEquals(long unexpected,
long actual)
Asserts that two longs are not equals. If they are, an AssertionError without a message is thrown.
Parameters:
unexpected - unexpected value to check
actual - the value to check against unexpected

assertNotEquals

public static void assertNotEquals(String message,
double unexpected,
double actual,
double delta)
Asserts that two doubles are not equal to within a positive delta. If they are, an AssertionError is thrown with the given message. If the unexpected value is infinity then the delta value is ignored. NaNs are considered equal: assertNotEquals(Double.NaN, Double.NaN, *) fails
Parameters:
message - the identifying message for the AssertionError (null okay)
unexpected - unexpected value
actual - the value to check against unexpected
delta - the maximum delta between unexpected and actual for which both numbers are still considered equal.

assertNotEquals

public static void assertNotEquals(double unexpected,
double actual,
double delta)
Asserts that two doubles are not equal to within a positive delta. If they are, an AssertionError is thrown. If the unexpected value is infinity then the delta value is ignored.NaNs are considered equal: assertNotEquals(Double.NaN, Double.NaN, *) fails
Parameters:
unexpected - unexpected value
actual - the value to check against unexpected
delta - the maximum delta between unexpected and actual for which both numbers are still considered equal.

assertNotEquals

public static void assertNotEquals(float unexpected,
float actual,
float delta)
Asserts that two floats are not equal to within a positive delta. If they are, an AssertionError is thrown. If the unexpected value is infinity then the delta value is ignored.NaNs are considered equal: assertNotEquals(Float.NaN, Float.NaN, *) fails
Parameters:
unexpected - unexpected value
actual - the value to check against unexpected
delta - the maximum delta between unexpected and actual for which both numbers are still considered equal.

assertArrayEquals

public static void assertArrayEquals(String message,
Object[] expecteds,
Object[] actuals)
throws org.junit.internal.ArrayComparisonFailure
Asserts that two object arrays are equal. If they are not, an AssertionError is thrown with the given message. If expecteds and actuals are null, they are considered equal.
Parameters:
message - the identifying message for the AssertionError (null okay)
expecteds - Object array or array of arrays (multi-dimensional array) with expected values.
actuals - Object array or array of arrays (multi-dimensional array) with actual values
Throws:
org.junit.internal.ArrayComparisonFailure

assertArrayEquals

public static void assertArrayEquals(Object[] expecteds,
Object[] actuals)
Asserts that two object arrays are equal. If they are not, an AssertionError is thrown. If expected and actual are null, they are considered equal.
Parameters:
expecteds - Object array or array of arrays (multi-dimensional array) with expected values
actuals - Object array or array of arrays (multi-dimensional array) with actual values

assertArrayEquals

public static void assertArrayEquals(String message,
boolean[] expecteds,
boolean[] actuals)
throws org.junit.internal.ArrayComparisonFailure
Asserts that two boolean arrays are equal. If they are not, an AssertionError is thrown with the given message. If expecteds and actuals are null, they are considered equal.
Parameters:
message - the identifying message for the AssertionError (null okay)
expecteds - boolean array with expected values.
actuals - boolean array with expected values.
Throws:
org.junit.internal.ArrayComparisonFailure

assertArrayEquals

public static void assertArrayEquals(boolean[] expecteds,
boolean[] actuals)
Asserts that two boolean arrays are equal. If they are not, an AssertionError is thrown. If expected and actual are null, they are considered equal.
Parameters:
expecteds - boolean array with expected values.
actuals - boolean array with expected values.

assertArrayEquals

public static void assertArrayEquals(String message,
byte[] expecteds,
byte[] actuals)
throws org.junit.internal.ArrayComparisonFailure
Asserts that two byte arrays are equal. If they are not, an AssertionError is thrown with the given message.
Parameters:
message - the identifying message for the AssertionError (null okay)
expecteds - byte array with expected values.
actuals - byte array with actual values
Throws:
org.junit.internal.ArrayComparisonFailure

assertArrayEquals

public static void assertArrayEquals(byte[] expecteds,
byte[] actuals)
Asserts that two byte arrays are equal. If they are not, an AssertionError is thrown.
Parameters:
expecteds - byte array with expected values.
actuals - byte array with actual values

assertArrayEquals

public static void assertArrayEquals(String message,
char[] expecteds,
char[] actuals)
throws org.junit.internal.ArrayComparisonFailure
Asserts that two char arrays are equal. If they are not, an AssertionError is thrown with the given message.
Parameters:
message - the identifying message for the AssertionError (null okay)
expecteds - char array with expected values.
actuals - char array with actual values
Throws:
org.junit.internal.ArrayComparisonFailure

assertArrayEquals

public static void assertArrayEquals(char[] expecteds,
char[] actuals)
Asserts that two char arrays are equal. If they are not, an AssertionError is thrown.
Parameters:
expecteds - char array with expected values.
actuals - char array with actual values

assertArrayEquals

public static void assertArrayEquals(String message,
short[] expecteds,
short[] actuals)
throws org.junit.internal.ArrayComparisonFailure
Asserts that two short arrays are equal. If they are not, an AssertionError is thrown with the given message.
Parameters:
message - the identifying message for the AssertionError (null okay)
expecteds - short array with expected values.
actuals - short array with actual values
Throws:
org.junit.internal.ArrayComparisonFailure

assertArrayEquals

public static void assertArrayEquals(short[] expecteds,
short[] actuals)
Asserts that two short arrays are equal. If they are not, an AssertionError is thrown.
Parameters:
expecteds - short array with expected values.
actuals - short array with actual values

assertArrayEquals

public static void assertArrayEquals(String message,
int[] expecteds,
int[] actuals)
throws org.junit.internal.ArrayComparisonFailure
Asserts that two int arrays are equal. If they are not, an AssertionError is thrown with the given message.
Parameters:
message - the identifying message for the AssertionError (null okay)
expecteds - int array with expected values.
actuals - int array with actual values
Throws:
org.junit.internal.ArrayComparisonFailure

assertArrayEquals

public static void assertArrayEquals(int[] expecteds,
int[] actuals)
Asserts that two int arrays are equal. If they are not, an AssertionError is thrown.
Parameters:
expecteds - int array with expected values.
actuals - int array with actual values

assertArrayEquals

public static void assertArrayEquals(String message,
long[] expecteds,
long[] actuals)
throws org.junit.internal.ArrayComparisonFailure
Asserts that two long arrays are equal. If they are not, an AssertionError is thrown with the given message.
Parameters:
message - the identifying message for the AssertionError (null okay)
expecteds - long array with expected values.
actuals - long array with actual values
Throws:
org.junit.internal.ArrayComparisonFailure

assertArrayEquals

public static void assertArrayEquals(long[] expecteds,
long[] actuals)
Asserts that two long arrays are equal. If they are not, an AssertionError is thrown.
Parameters:
expecteds - long array with expected values.
actuals - long array with actual values

assertArrayEquals

public static void assertArrayEquals(String message,
double[] expecteds,
double[] actuals,
double delta)
throws org.junit.internal.ArrayComparisonFailure
Asserts that two double arrays are equal. If they are not, an AssertionError is thrown with the given message.
Parameters:
message - the identifying message for the AssertionError (null okay)
expecteds - double array with expected values.
actuals - double array with actual values
delta - the maximum delta between expecteds[i] and actuals[i] for which both numbers are still considered equal.
Throws:
org.junit.internal.ArrayComparisonFailure

assertArrayEquals

public static void assertArrayEquals(double[] expecteds,
double[] actuals,
double delta)
Asserts that two double arrays are equal. If they are not, an AssertionError is thrown.
Parameters:
expecteds - double array with expected values.
actuals - double array with actual values
delta - the maximum delta between expecteds[i] and actuals[i] for which both numbers are still considered equal.

assertArrayEquals

public static void assertArrayEquals(String message,
float[] expecteds,
float[] actuals,
float delta)
throws org.junit.internal.ArrayComparisonFailure
Asserts that two float arrays are equal. If they are not, an AssertionError is thrown with the given message.
Parameters:
message - the identifying message for the AssertionError (null okay)
expecteds - float array with expected values.
actuals - float array with actual values
delta - the maximum delta between expecteds[i] and actuals[i] for which both numbers are still considered equal.
Throws:
org.junit.internal.ArrayComparisonFailure

assertArrayEquals

public static void assertArrayEquals(float[] expecteds,
float[] actuals,
float delta)
Asserts that two float arrays are equal. If they are not, an AssertionError is thrown.
Parameters:
expecteds - float array with expected values.
actuals - float array with actual values
delta - the maximum delta between expecteds[i] and actuals[i] for which both numbers are still considered equal.

assertEquals

public static void assertEquals(String message,
double expected,
double actual,
double delta)
Asserts that two doubles are equal to within a positive delta. If they are not, an AssertionError is thrown with the given message. If the expected value is infinity then the delta value is ignored. NaNs are considered equal: assertEquals(Double.NaN, Double.NaN, *) passes
Parameters:
message - the identifying message for the AssertionError (null okay)
expected - expected value
actual - the value to check against expected
delta - the maximum delta between expected and actual for which both numbers are still considered equal.

assertEquals

public static void assertEquals(String message,
float expected,
float actual,
float delta)
Asserts that two floats are equal to within a positive delta. If they are not, an AssertionError is thrown with the given message. If the expected value is infinity then the delta value is ignored. NaNs are considered equal: assertEquals(Float.NaN, Float.NaN, *) passes
Parameters:
message - the identifying message for the AssertionError (null okay)
expected - expected value
actual - the value to check against expected
delta - the maximum delta between expected and actual for which both numbers are still considered equal.

assertNotEquals

public static void assertNotEquals(String message,
float unexpected,
float actual,
float delta)
Asserts that two floats are not equal to within a positive delta. If they are, an AssertionError is thrown with the given message. If the unexpected value is infinity then the delta value is ignored. NaNs are considered equal: assertNotEquals(Float.NaN, Float.NaN, *) fails
Parameters:
message - the identifying message for the AssertionError (null okay)
unexpected - unexpected value
actual - the value to check against unexpected
delta - the maximum delta between unexpected and actual for which both numbers are still considered equal.

assertEquals

public static void assertEquals(long expected,
long actual)
Asserts that two longs are equal. If they are not, an AssertionError is thrown.
Parameters:
expected - expected long value.
actual - actual long value

assertEquals

public static void assertEquals(String message,
long expected,
long actual)
Asserts that two longs are equal. If they are not, an AssertionError is thrown with the given message.
Parameters:
message - the identifying message for the AssertionError (null okay)
expected - long expected value.
actual - long actual value

assertEquals

@Deprecated
public static void assertEquals(double expected,
double actual)
Deprecated. Use assertEquals(double expected, double actual, double delta) instead

assertEquals

@Deprecated
public static void assertEquals(String message,
double expected,
double actual)
Deprecated. Use assertEquals(String message, double expected, double actual, double delta) instead

assertEquals

public static void assertEquals(double expected,
double actual,
double delta)
Asserts that two doubles are equal to within a positive delta. If they are not, an AssertionError is thrown. If the expected value is infinity then the delta value is ignored.NaNs are considered equal: assertEquals(Double.NaN, Double.NaN, *) passes
Parameters:
expected - expected value
actual - the value to check against expected
delta - the maximum delta between expected and actual for which both numbers are still considered equal.

assertEquals

public static void assertEquals(float expected,
float actual,
float delta)
Asserts that two floats are equal to within a positive delta. If they are not, an AssertionError is thrown. If the expected value is infinity then the delta value is ignored. NaNs are considered equal: assertEquals(Float.NaN, Float.NaN, *) passes
Parameters:
expected - expected value
actual - the value to check against expected
delta - the maximum delta between expected and actual for which both numbers are still considered equal.

assertNotNull

public static void assertNotNull(String message,
Object object)
Asserts that an object isn't null. If it is an AssertionError is thrown with the given message.
Parameters:
message - the identifying message for the AssertionError (null okay)
object - Object to check or null

assertNotNull

public static void assertNotNull(Object object)
Asserts that an object isn't null. If it is an AssertionError is thrown.
Parameters:
object - Object to check or null

assertNull

public static void assertNull(String message,
Object object)
Asserts that an object is null. If it is not, an AssertionError is thrown with the given message.
Parameters:
message - the identifying message for the AssertionError (null okay)
object - Object to check or null

assertNull

public static void assertNull(Object object)
Asserts that an object is null. If it isn't an AssertionError is thrown.
Parameters:
object - Object to check or null

assertSame

public static void assertSame(String message,
Object expected,
Object actual)
Asserts that two objects refer to the same object. If they are not, an AssertionError is thrown with the given message.
Parameters:
message - the identifying message for the AssertionError (null okay)
expected - the expected object
actual - the object to compare to expected

assertSame

public static void assertSame(Object expected,
Object actual)
Asserts that two objects refer to the same object. If they are not the same, an AssertionError without a message is thrown.
Parameters:
expected - the expected object
actual - the object to compare to expected

assertNotSame

public static void assertNotSame(String message,
Object unexpected,
Object actual)
Asserts that two objects do not refer to the same object. If they do refer to the same object, an AssertionError is thrown with the given message.
Parameters:
message - the identifying message for the AssertionError (null okay)
unexpected - the object you don't expect
actual - the object to compare to unexpected

assertNotSame

public static void assertNotSame(Object unexpected,
Object actual)
Asserts that two objects do not refer to the same object. If they do refer to the same object, an AssertionError without a message is thrown.
Parameters:
unexpected - the object you don't expect
actual - the object to compare to unexpected

assertEquals

@Deprecated
public static void assertEquals(String message,
Object[] expecteds,
Object[] actuals)
Deprecated. use assertArrayEquals
Asserts that two object arrays are equal. If they are not, an AssertionError is thrown with the given message. If expecteds and actuals are null, they are considered equal.
Parameters:
message - the identifying message for the AssertionError (null okay)
expecteds - Object array or array of arrays (multi-dimensional array) with expected values.
actuals - Object array or array of arrays (multi-dimensional array) with actual values

assertEquals

@Deprecated
public static void assertEquals(Object[] expecteds,
Object[] actuals)
Deprecated. use assertArrayEquals
Asserts that two object arrays are equal. If they are not, an AssertionError is thrown. If expected and actual are null, they are considered equal.
Parameters:
expecteds - Object array or array of arrays (multi-dimensional array) with expected values
actuals - Object array or array of arrays (multi-dimensional array) with actual values

assertThat

public static <T> void assertThat(T actual,
Matcher<? super T> matcher)
Asserts that actual satisfies the condition specified by matcher. If not, an AssertionError is thrown with information about the matcher and failing value. Example:
   assertThat(0, is(1)); // fails:
// failure message:
// expected: is <1>
// got value: <0>
assertThat(0, is(not(1))) // passes

org.hamcrest.Matcher does not currently document the meaning of its type parameter T. This method assumes that a matcher typed as Matcher<T> can be meaningfully applied only to values that could be assigned to a variable of type T.

Type Parameters:
T - the static type accepted by the matcher (this can flag obvious compile-time problems such as assertThat(1, is("a"))
Parameters:
actual - the computed value being compared
matcher - an expression, built of Matchers, specifying allowed values
See Also:
CoreMatchersMatcherAssert

assertThat

public static <T> void assertThat(String reason,
T actual,
Matcher<? super T> matcher)
Asserts that actual satisfies the condition specified by matcher. If not, an AssertionError is thrown with the reason and information about the matcher and failing value. Example:
   assertThat("Help! Integers don't work", 0, is(1)); // fails:
// failure message:
// Help! Integers don't work
// expected: is <1>
// got value: <0>
assertThat("Zero is one", 0, is(not(1))) // passes

org.hamcrest.Matcher does not currently document the meaning of its type parameter T. This method assumes that a matcher typed as Matcher<T> can be meaningfully applied only to values that could be assigned to a variable of type T.

Type Parameters:
T - the static type accepted by the matcher (this can flag obvious compile-time problems such as assertThat(1, is("a"))
Parameters:
reason - additional information about the error
actual - the computed value being compared
matcher - an expression, built of Matchers, specifying allowed values
See Also:
CoreMatchersMatcherAssert

Junit4断言的更多相关文章

  1. Junit4 断言新方法

    话不多少说,直接上代码 package ASSERTTEST; import org.junit.Assert; import org.hamcrest.*;import org.junit.Test ...

  2. 5月3日上课笔记-properties文件,junit测试,mvc封层等

    StringBuffer 线程安全,效率低 StringBuilder 线程不安全,效率高 判断数组是null还是空数组 null 空数组 int[] array=null; int[] array2 ...

  3. Junit4中的新断言assertThat的使用方法

    如果需要是用assertThat需要在项目中引入junit4的jar包.(匹配器和断言方法在junit4的jar包中都能找到,引入就可以了) 下面是常用断言的代码 1 import static or ...

  4. SpringBoot JUnit4的断言和注解

    Junit4的断言常用方法: assertArrayEquals( new Object[]{ studentService.likeName("小明2").size() > ...

  5. Junit3断言

    在Robotium自动化测试的过程中,发现没有断言的脚本是没有意义的,现整理Junit3和Junit4的断言,供日后查阅. http://junit.org/ Junit3断言API: http:// ...

  6. Junit3与Junit4的区别

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

  7. 利用Junit4进行程序模块的测试,回归测试

    ①在你的工程里导入JUnit4的包 ②右击创建JUnit测试类,在测试类中编写测试代码即可. JUnit 目前需要掌握的有一下几点: Fixture系列:BeforeClass,AfterClass, ...

  8. Java魔法堂:JUnit4使用详解

    目录                                                                                              1. 开 ...

  9. 用JUnit4进行单元测试

    转载:http://tonl.iteye.com/blog/1948869 参考: http://thihy.iteye.com/blog/1771826 http://developer.51cto ...

随机推荐

  1. &lbrack;地图SkyLine二次开发&rsqb;框架&lpar;3&rpar;

    上节将显示我们地图的OBJECT控件,布了一下局,但地图没有进行加载. 这是因为我们要在另一个页面,对OBJECT控件进行地图加载,并且得到该控件的sgworld,以便对其进行我们想要的开发. 这里, ...

  2. yum -y install与yum install有什么不同

    yum -y install 包名(支持*) :自动选择y,全自动 yum install 包名(支持*) :手动选择y or n yum remove 包名(不支持*) rpm -ivh 包名(支持 ...

  3. 安装&sol;移除Windows服务

    在工作中,涉及到相关Windows的开发时,常常要安装.移除Windows服务程序.一般地,可通过cmd命令行操作来完成~ cd 服务程序所在目录 *.exe -i // 安装服务 *.exe -s ...

  4. 让U盘永不中毒的解决办法

    一.背景: 在学校上课的时候,有个老师很潇洒的拿着一个U盘就来教室上课了.然后快上课的时候在电脑上准备播放课件.注意,这一瞬间其妙的事情发生了,课件因为他的U盘中病毒了,打不开了,老师当时笑了.后来又 ...

  5. 同步git修改文件到远端服务器脚本

    #!/usr/bin/perl -w @files=`git status -s` ; @sync_files = (); foreach (@files) { ); # 固定前2个字符为状态 + 1 ...

  6. 从Windows 8 安装光盘安装&period;NET Framework 3&period;5&period;1

    在安装一些应用时, 例如安装 Oracle, 可能会缺少了安装 .Net FrameWork 3.5.1 无法继续. 最简单的方法当时是,直接进 控制面板, 在添加删除程序内, 选择增加Windows ...

  7. vc&plus;&plus; 内存连续读写操作

    //初始化内存 int *data=(int*)malloc(sizeof(int)*4); ZeroMemory(data, sizeof(int)*4); int *m=(int*)malloc( ...

  8. spring字符编码设置

    <filter> <filter-name>encodingFilter</filter-name> <filter-class>org.springf ...

  9. sed找到重复的行

    sed之仅打印相邻重复的行 cat file  aaa bbb bbb ccc ddd eee eee fff   只显示重复的行: bbb bbb eee eee   sed -n ':a;N;/\ ...

  10. 线段树hdu1754

    #include<iostream>#include<stdio.h>using namespace std;const int maxa=200005;int val[max ...