You need to put it in try/catch and in catch block do
try{
}catch(Exception e){
Assert.fail(e.getMessage());
}finally{
// CLOSE ANY OPEN RESOURCES HERE !!!!
}
If you have any open resources, don't forget to close them in finally block.