*
* @param event, the test
* @throws PerformanceException if the test did not end within the specified time
*/
private void verifyPerformance(Test event) throws PerformanceException {
TestResult result = testResultInst.get();
if(result != null)
{
//check if we have set a threshold
Performance performance = null;
Annotation[] annotations = event.getTestMethod().getDeclaredAnnotations();
for(Annotation a : annotations)
if(a.annotationType().getName().equals(Performance.class.getCanonicalName()))
performance = (Performance) a;
if(performance != null)
{
//System.out.println("For test: "+event.toString()+", it took: "+(result.getEnd()-result.getStart()));
if(performance.time() > 0 &&
performance.time() < (result.getEnd()-result.getStart()))
{
result.setStatus(TestResult.Status.FAILED);
result.setThrowable(
new PerformanceException("The test didnt finish within the specified time: "
+performance.time()+"ms, it took "+(result.getEnd()-result.getStart())+"ms."));
}
// fetch suiteResult, get the correct classResult and append the test to that
// classResult.
PerformanceSuiteResult suiteResult = suiteResultInst.get();
if(suiteResult != null) {
suiteResult.getResult(event.getTestClass().getName()).addMethodResult(
new PerformanceMethodResult(
performance.time(),
(result.getEnd()-result.getStart()),
event.getTestMethod()));
}
}
}
}