自动化测试断言Assent的使用

 Assent 断言模板包含如下方法:

assert.fail(actual, expected, message, operator)

assert.ok(value, [message])

assert.equal(actual, expected, [message])

assert.notEqual(actual, expected, [message])
assert.deepEqual(actual, expected, [message])
assert.notDeepEqual(actual, expected, [message])
assert.strictEqual(actual, expected, [message])
assert.notStrictEqual(actual, expected, [message])
assert.throws(block, [error], [message])
assert.doesNotThrow(block, [error], [message])
assert.ifError(value)

 1     public static boolean flag=true;
 2     public static void verifyEquals(Object actual,Object expected){
 3         try {
 4             Assert.assertEquals(actual, expected);
 5             System.out.println("断言成功!"+flag);
 6         }catch (Error e){
 7             flag=false;
 8             System.out.println("断言失败"+flag);
 9         }
10     }
1   public static void verifyEquals(Object actual,Object expected,String message){
2         try {
3             Assert.assertEquals(message,actual,expected);
4             System.out.println("断言成功!");
5         }catch (Error e){
6             flag=false;
7             System.out.println("断言失败"+flag);
8         }
9     }

 

posted @ 2017-04-19 20:03  Sunny*  阅读(1546)  评论(0编辑  收藏  举报