Grails Services / Transactions / RuntimeException / Testing
Posted
by
Rob
on Stack Overflow
See other posts from Stack Overflow
or by Rob
Published on 2011-01-11T07:47:51Z
Indexed on
2011/01/11
7:53 UTC
Read the original article
Hit count: 193
I'm testing come code in a service with transactional set to true , which talks to a customer supplied web service the main part of which looks like
class BarcodeService {
..
/// some stuff ...
try{
cancelBarCodeResponse = cancelBarCode(cancelBarcodeRequest)
} catch(myCommsException e) {
throw new RuntimeException(e)
}
...
where myCommsException extends Exception ..
I have a test which looks like
// As no connection from my machine, it should fail ..
shouldFailWithCause(RuntimeException){
barcodeServices.cancelBarcodeDetails()
}
The test fails cause it's catching a myCommsException rather than the RuntimeException i thought i'd converted it to .. Anyone care to point out what i'm doing wrong ? Also will the fact that it's not a RuntimeException mean any transaction related info done before my try/catch actually be written out rather than thrown away ??
Thanks
© Stack Overflow or respective owner