-(defmethod run-protected ((test test-case) res &key (handle-errors t))
- (handler-case
- (run-base test)
- (assertion-failed (condition)
- (add-failure res test condition))
- (serious-condition (condition)
- (add-error res test condition)))
+(defmethod run-protected ((test test-case) res
+ &key (handle-errors t) test-condition)
+ (if handle-errors
+ (handler-case
+ (run-base test)
+ (assertion-failed (condition)
+ (add-failure res test condition))
+ (t (condition)
+ (when (and test-condition
+ (not (typep condition test-condition)))
+ (add-failure res test
+ (make-instance 'assertion-failed
+ :format-control
+ "Assert condition ~A, but condition ~A signaled"
+ :format-arguments
+ (list test-condition condition)))))
+ (serious-condition (condition)
+ (add-error res test condition))
+ (:no-error ()
+ (when test-condition
+ (add-failure res test
+ (make-instance 'assertion-failed
+ :format-control "Assert condition ~A, but no condition signaled"
+ :format-arguments (list test-condition))))))
+ (run-base test))