How to write tests for bad input, e.g. to check its proper handling
2 次查看(过去 30 天)
显示 更早的评论
To be more concrete: It's clear how to write tests that validate some expected outputs (testCase.validateEqual() etc.).
However, how do I validate that e.g. some exception was properly thrown as a response to e.g. some bad input data? Usually if an exception occurs in the function-under-test, the corresponding test function is marked as both "failed" and "incomplete".
0 个评论
采纳的回答
Steven Lord
2016-1-2
Use testCase.verifyError. The first input should be a function handle that will throw the error when evaluated, and the second should be the error identifier.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Testing Frameworks 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!