How to write tests for bad input, e.g. to check its proper handling
조회 수: 1 (최근 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!