?????????????????????
???????????? ???????[ 2013/2/26 9:38:06 ] ????????
????????С???????????????????·????У????嵥 2 ??????????????????£?????? updateContent() ?????????帴????????? 5????????????????????????????????????в????
?嵥 2. ??????????? getStatus
private String getStatus(IStatus status?? List lastChangedStatus) {
String retstatus = null;
if ( lastChangedStatus != null && lastChangedStatus.size() > 0 ){
if ( status.getId() == ((IStatus)lastChangedStatus.get(0)).getId() ){
retstatus = "Change in Current status";
}else{
retstatus = "Account Previously Changed in: " +
((IStatus)lastChangedStatus.get(0)).getStatusIdentification();
}
}else{
retstatus = "No Changes Since Creation";
}
return retstatus;
}
???????? updateContent() ???????е???????滻????′????? getStatus() ?????????????嵥 3 ?????
?嵥 3. ???? getStatus
//...other code above
String iStatus = getStatus(status?? lastChangedStatus);
//...more code below
???????????е??????????????????????
??????з???
????????? ?嵥 2 ?ж?????? getStatus() ??????????? private???????????????? ???????????????γ????????????????????????????????????
??????????? public??
??????????? protected????????????????????????С?
??????н????????????????????????????????
??????????????????????е??????????? private??????????? JUnit ????????????????
PrivateAccessor ??
JUnit ?????????Щ???????????????? JUnit ???в?????????????????? PrivateAccessor ??????? private ???????????С??????????????????????????PrivateAccessor ??? JUnit ?????????????????????????????κβ?????????? TestNG??
PrivateAccessor ?? API ??? —— ?? invoke() ???????????????????? String???????????????????????????????? Class ?? Object ?????У???????????÷?????????????PrivateAccessor ??????????? Java ????? API ???????????????????????????????????ж??????????????????????????????????????
???嵥 4 ?У????? getStatus() ????????????????????? null??invoke() ??????????? Object???????????? String????????? invoke() ??????????? throws Throwable???????????????ò??????????????????????????
?嵥 4. ??????з???
public void testGetStatus() throws Throwable{
AccountAction action = new AccountAction();
String value = (String)PrivateAccessor.invoke(action??
"getStatus"?? new Class[]{IStatus.class?? List.class}??
new Object[]{null?? null});
assertEquals("should be No Changes Since Creation"??
"No Changes Since Creation"?? value);
}
????? invoke() ???????????????????? Object ????????嵥 4 ?????????? Class??????????? private ??????? static ?????
??????????÷?????? private ?????????????????????????????????????????? getStatus() ??????????????????????????????????????????????????????????????
??????
???????????????????????д????ó????е?·??????ó????????????????е?????????????????????·???????????????????????Щ·???????С???????У????????????????ЩС??????????????????
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11