0

transactional が true に設定されたサービスでコードをテストしています。これは、顧客が提供する Web サービスと通信し、その主要部分は次のようになります。

class BarcodeService { 
..  
/// some stuff  ...  

try{
      cancelBarCodeResponse = cancelBarCode(cancelBarcodeRequest)
} catch(myCommsException e) {
  throw new RuntimeException(e)
}
... 

myCommsException は Exception を拡張します。

次のようなテストがあります

// As no connection from my machine, it should fail ..

shouldFailWithCause(RuntimeException){
  barcodeServices.cancelBarcodeDetails()
}

テストが失敗したため、RuntimeException ではなく myCommsException をキャッチしているため、変換したと思っていました。また、それが RuntimeException ではないという事実は、try/catch が破棄されるのではなく、実際に書き出される前に行われたトランザクション関連の情報を意味しますか??

ありがとう

4

1 に答える 1

0

From what I see, it looks ok. The problem might be in the ///some stuff and the ... parts of the code. Use a debugger to find out exactly where the exception is being thrown.

于 2011-01-11T19:42:05.607 に答える