?????????л?δ?????????Ь??????????????????????????????????????????д?????????????????????????????……??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
???????????·
??????ν?????????????????????????????????????????????????????????????????title????????????????????????????????????????????????????????????????????????????title??“???????”????????????????????л?????β???????????????н?????????tilte?????title??£????????????????pass????????£???????????????failed????

??????????????
??????????????????????????????Junit??TestNG????Assert????????з???????????????Junit????TestNG????????????????????????????????и????????????????Junit????TestNG???????Assert??????????????????????????ж??????????????????????????????????ж????????????????????????????????????????????????????????????Junit??TestNG????????????????????????????????????????????????ж??????????????try-catch???????????????????????????????Assert???????????????????治?????????????talk is cheap. show me the code??????????ɡ?
public class Assert {
public static final String STARTSWITH = "startsWith";
public static final String ENDSWITH = "endsWith";
public static final String CONTAINS = "contains";
public static boolean assertSame(Object actual?? Object expected?? String msg?? String tag){
boolean isMatch = false;
if(assertEquals(actual??expected??false)){
BaseCase.log.i("???"+ msg +"??""+actual+"" ????????"+ msg +"??""+expected+"" ?????");
return true;
}
String text = "??????";
switch (tag){
case Assert.STARTSWITH:
isMatch = actual.toString().startsWith(expected.toString());
text = "?????";
break;
case Assert.ENDSWITH:
isMatch = actual.toString().endsWith(expected.toString());
text = "??????";
break;
case Assert.CONTAINS:
isMatch = actual.toString().contains(expected.toString());
text = "??????";
break;
default:
break;
}
if(isMatch){
BaseCase.log.i("???"+ msg +"??""+actual+"" ??"+ text +" ????"+ msg +"??""+expected+""");
return true;
}else{
BaseCase.log.e("???"+ msg +"??""+actual+"" ??"+ text +" ????"+ msg +"??""+expected+""");
return false;
}
}
public static boolean assertEquals(Object actual?? Object expected?? String msg){
try {
org.junit.Assert.assertEquals(actual?? expected);
BaseCase.log.i("???"+ msg +"??""+actual+"" ????????"+ msg +"??""+expected+"" ?????");
return true;
} catch (Error e) {
BaseCase.log.e("???"+ msg +"??""+actual+"" ????????"+ msg +"??""+expected+"" ?????");
return false;
}
}
}
????????????2????????????????????????????????????????????????
??????ú?????????С????????????????~
//?????????????????????????
@Test
public void testTitle(){
//????????????
String actualTitle = getTitle();
String exceptedTitle = "XXXXX";
Assert.assertSame(actualTitle??  exceptedTitle?? "????"?? Assert.STARTSWITH );
Assert.assertEquals(actualTitle??  exceptedTitle?? "????");
}
????ok??????????д??????????????????????????????鷳??????