1. 在xmlsuite 解析 tag="listeners"的資訊,加入addlistener
publicclass
xmlsuite
@onelementlist(tag = "listeners", attributes = )
public
void
onlistenerelement(string classname)
2.在執行test的時候,設定好不同執行狀態(pass,failed)再執行 runtestlisteners(testresult),同時把testresult傳入
privateitestresult invokemethod(object instance,
final
itestngmethod tm,
object parametervalues,
intparametersindex,
xmlsuite suite,
mapparams,
itestclass testclass,
itestngmethod beforemethods,
itestngmethod aftermethods,
configurationgroupmethods groupmethods,
failurecontext failurecontext)
else
testresult.setstatus(itestresult.success);
} else
}else
}catch
(invocationtargetexception ite)
catch(threadexecutionexception tee)
else
testresult.setstatus(itestresult.failure);
}catch(throwable thr)
finally
////
increment the invocation count for this method
//run invokedmethodlisteners after updating testresult
runinvokedmethodlisteners(after_invocation, invokedmethod, testresult);
runtestlisteners(testresult);
////
invoke aftermethods only if
//- lasttimeonly is not set
//- lasttimeonly is set, and we are reaching the last invocationcount
//invokeconfigurations(testclass, tm,
filterconfigurationmethods(tm, aftermethods,
false
/*beforemethods
*/),
suite, params, parametervalues,
instance,
testresult);
////
invoke aftergroups configurations
//invokeaftergroupsconfigurations(testclass, tm, groupmethods, suite,
params, instance);
//reset the test result last. if we do this too early, reporter.log()
//invocations from listeners will be discarded
reporter.setcurrenttestresult(null
);}
3.通過testresult的狀態分別呼叫 testlistener的各種方法(onstart,onfailed....),支援多個itestlistener噢
publicstatic
void runtestlisteners(itestresult tr, listlisteners)
case
itestresult.success_percentage_failure:
case
itestresult.failure:
case
itestresult.success:
case
itestresult.started:
default: }
}}return
testresult;
}
ConcurrentHashMap 原理簡要分析
在之前寫過hashtable 與hashmap 兩者之間的異同 通過前面文章,可以知道hashmap 中未進行同步考慮,而 hashtable 則使用了 synchronized 帶來的直接影響就是可選擇,我們可以在單執行緒時使用 hashmap 提高效率,而多執行緒時用 hashtable 來保證...
jQuery原理簡析
jquery原理簡析 function selector,context function jquery selector,context if typeof selector function 我們想要 selector 時就獲得乙個元素,且裡面有一些方法。這些方法要繫結在原型prototype上...
Vue原理 簡言
vue template 編譯 render function vnode 虛擬dom react jsx render function vnode 虛擬dom vue相當於react,angular更綜合一點。angular js則使用了 髒值檢測 react則採用避免直接操作dom的虛擬dom...