How to write tests for bad input, e.g. to check its proper handling

1 回表示 (過去 30 日間)
Ilya
Ilya 2016 年 1 月 2 日
コメント済み: Ilya 2016 年 1 月 3 日
This can be also related to the following StackOverflow question...
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".

採用された回答

Steven Lord
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.
  1 件のコメント
Ilya
Ilya 2016 年 1 月 3 日
Thanks, I think I missed or misunderstood this before

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeTesting Frameworks についてさらに検索

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by