I think the reason is that you will never get to the else block of this condition
Assert.assertTrue(test);
if(test){
resultado = TestLinkAPIResults.TEST_PASSED;
} else {
//
}
When Asser fails, new AssertionError
occurs so you never make it even to the if condition. You also can't catch this error because Exception
derives from Throwable
and Error
too. So you basically can remove the condition and try to catch Error
- which is not really best practice but it will work. The best thing to use in these situations is listener but I am not sure how this works with @Parameters
. However, you can always do it like this
try{
Assert.assertTrue(test);
resultado = TestLinkAPIResults.TEST_PASSED;
} catch (AsertionError e){
resultado = TestLinkAPIResults.TEST_FAILED;
nota = fraud.getError();
e.printStackTrace();
}finally{
ResultadoExecucao.reportTestCaseResult(PROJETO, nombrePlan, nomTL_validacionCantidadMensajes, nombreBuild, nota, resultado);
}