VectorCAST Handling Exceptions

How does VectorCAST handle exceptions in the code?
  • Do you use exception specifications in your source code?

    If your function has an exception specification (e.g. void foo() throw(int)), then a <<throw>> node will appear allowing you to set an expected value. If your function does not have an exception specification and you want to test or set an expected value for an exception, then you must either edit your source code or create a wrapper function which does have a specification. This wrapper can be defined inside unit appendix user code (Environment | User Code | Edit). A rebuild is necessary after any appendix user code has been added.

    If you select Tools | Options | Execute, you should see an option labeled Fail on unexpected exceptions. Toggling this check box will control whether or not the test fails.
  • Are you trying to figure out how to raise an exception from a stub?

    If you want an exception to be thrown via user code during the execution of your function under test, the user code will either have to be in configure stubs user code or parameter user code for a stub parameter. The reason for this is that stub calls are the only points where user code can be called during the actual execution of your function under test. 

    If you have an exception specification for the stub, however, it will be indicated in the parameter tree for that stub and will not require user code to set or test the value.

Article ID: 1489
Last updated: 2019-10-31
Revision: 1
VectorCAST -> Troubleshooting -> VectorCAST Handling Exceptions